There are numerous problems with your code, including the fact that despite declaring and setting a reference to the document you want to work with, your code then reverts to using 'ActiveDocument'. This and most of the rest of the code you're using if you simply used a purpose-designed template at the '.Documents.Add' point, with the required Style definitions, table and other standard content in-situ, instead of trying to use a new document at the created from Word's default template then applying all that content and using hard formatting to override the existing Styles. If the template contained bookmarks to denote where the QueryA & QueryB output were to go, that would further simplify the document creation.
PS: When posting code, please use the code tags, indicated by the # button on the posting menu.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
|