Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combining two Word documents - How?
Message
From
30/01/2002 09:01:10
 
 
To
29/01/2002 14:29:57
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00612320
Message ID:
00612658
Views:
34
>>Try this:
>>*---------------------
>>lcfile1="c:\encrypting.doc"
>>lcfile2="c:\If Operating Systems were beers.doc"
>>wdStory=6
>>wdSectionBreakNextPage=2
>>
>>oWord = CREATEOBJECT("word.application")
>>with oWord
>> .Documents.open(lcfile1)
>> .Selection.EndKey(wdStory)
>> .Selection.InsertBreak(wdSectionBreakNextPage)
>> .Selection.InsertFile(lcfile2,"", .f.,.f.,.f.)
>>endwith

You should be able to speed this up a little by using the Range object instead of the Selection object. (In general, you should use Range wherever possible rather than Selection.)

WITH oWord
.Documents.Open(lcFile1)
oRange = .ActiveDocument.Range()
ENDWITH

WITH oRange
.Collapse(wdCollapseEnd)
.InsertBreak( wdSectionBreakNextPage )
.Collapse(wdCollapseEnd)
.InsertFile(lcFile2, "", .f., .f., .f.)
ENDWITH

Warning: untested code, just a translation of Yuri's code.

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform