Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Divide word doc sections into word docs
Message
De
11/11/2009 06:42:39
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
10/11/2009 17:11:24
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01434149
Message ID:
01434200
Vues:
72
This message has been marked as the solution to the initial question of the thread.
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform