Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an application that outputs reports as MS Word documents. This is because the user needs to occasionally modify the reports. I have a 1 page template for one of the reports and the report can be 1 page or 50 pages depending upon the data. I can create all the documents properly, but when using insert to create one document containing all the pages, it fails. How do I get this to work

the file names are in a table
VB
    For lngZ = 1 To lngRecs
         strTempDoc = Tempset("FileName")
          If lngZ = 1 Then
             objWord.Documents.Add (strTempDoc) '  for the first document to be added use Documents.Add method
             Selection.MoveEnd Unit:=wdLine, Count:=1
          Else
               bX = InsertFile(strTempDoc, Range, ConfirmConversions, Link, Attachment)
               Selection.MoveEnd Unit:=wdLine, Count:=1
          End If
'          intGG = Instance.EndKey(Unit:=6)   '''' here
'            Selection.EndKey Unit:=wdStory, Extend:=wdMove
            Tempset.MoveNext
            If Tempset.EOF Then
                Exit For
            End If
    Next
Posted
Updated 16-Dec-14 9:14am
v3

1 solution

 
Share this answer
 
Comments
Member 8572197 16-Dec-14 18:32pm    
does not work with word 2013
objWord.Selection.InsertFile & objWord.Selection.EndKey lines fail to compile

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900