Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Divide word doc sections into word docs
Message
From
11/11/2009 10:15:23
 
 
To
11/11/2009 06:42:39
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01434149
Message ID:
01434225
Views:
35
Thank you very much!

>>I received a letter which was created by mailmerge. each page is a section and a letter
>>I was asked to take each page and create an individual word documet
>>
>>i figured out ho to access the sections with a for 1 to sections.count loop
>>
>> lcText= oword.activedocument.Sections.Item[lnSectionCnt ].range.text
>>oRange = oword.activedocument.Sections.Item[lnSectionCnt ].range gives me an object
>>
>>can I now create a worddoc with that object and save it??
>>
>>Thanks
>>
>>
>>peter
>
>
>#Define wdSaveChanges	-1
>
>Local oWord, oDoc, ix, lcFileName, lcDocName, lcPath
>lcDocName = 'c:\My Folder\MyMerged.doc'
>lcPath = 'c:\My Folder\MergedDOCS'
>
>If !Directory(m.lcPath)
>  Md (m.lcPath)
>Endif
>
>oWord = Createobject('Word.Application')
>With oWord
>  .Documents.Open( m.lcDocName )
>  oDoc = .ActiveDocument
>  For ix = 1 To oDoc.Sections.Count
>    oDoc.Sections(m.ix).Range.Copy()
>    With .Documents.Add()
>      .Content.Paste
>      .Content.Find.Execute("^b", ,,,,,,,,"")
>      lcFileName = Forcepath(Forceext( ;
>        Juststem( m.lcDocName )+ Padl(m.ix,3,'0'), 'doc' ), m.lcPath )
>      .SaveAs( m.lcFileName )
>      .Close( wdSaveChanges	)
>    Endwith
>  Endfor
>  .Quit()
>Endwith
>
>
>PS: This might take a long time to complete.
>
>Cetin
Peter Cortiel
Previous
Reply
Map
View

Click here to load this message in the networking platform