Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combining multiple word documents into one
Message
De
06/04/2004 04:42:46
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
05/04/2004 17:58:40
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00892459
Message ID:
00892545
Vues:
18
>I have a situation where I'm generating 4 word documents from within a VFP app. All four have their own page numbering ('x' of 'y'). Each document has multiple sections, because of terms and conditions.
>
>I've been asked to write something that will combine all four into one document...but still retaining separate 'page x of y' on each of the four sections.
>
>I'm going to figure out from the Tamar/Della book how to accomplish this, but it seems I need to do something like the following.
>
>- Create a blank doc
>- insert doc 1
>- go to the bottom, insert a new page break and a new section, break, and reset to a one-section column (end of doc 1 has 2 columns, but beginning of doc 2 goes back to one column)
>- insert doc 2, and keep repeating
>
>Has anyone else tried this? If so, any 'gotchas' to be aware of?
>
>Thanks,
>Kevin

Or :
-Create a template doc with bookmarks for each doc separated by section breaks, page numbering set accordingly (or similarly a master document).
-Add a new doc based on that template (Documents.Add(m.lcTemplateFile))
-Replace bookmarks with other docs.

ie:
#DEFINE wdNormalView	1	
#DEFINE wdOutlineView	2	
#DEFINE wdPrintView	3	
#DEFINE wdPrintPreview	4	
#DEFINE wdMasterView	5	

lcTemplate = 'c:\myPath\template.doc'
lcMasterTypeTemplate = 'c:\myPath\mastertype.doc'
lcDoc1 = "c:\myPath\w1.doc"
lcDoc2 = "c:\myPath\w2.doc"
lcDoc3 = "c:\myPath\w3.doc"

oWord=createobject('Word.Application')
With oWord
 .DisplayAlerts = .F.
 .Documents.add(m.lcTemplate)
 With .ActiveDocument
 	.Bookmarks("doc1").Range.InsertFile(m.lcDoc1)
 	.Bookmarks("doc2").Range.InsertFile(m.lcDoc2)
 	.Bookmarks("doc3").Range.InsertFile(m.lcDoc3)
 EndWith
 .Visible = .t.
endwith

* Master Document way
oWord=createobject('Word.Application')
With oWord
 .DisplayAlerts = .F.
 .Documents.add(m.lcMasterTypeTemplate)
 With .ActiveDocument
    .ActiveWindow.ActivePane.View.Type = wdMasterView
    .Bookmarks("doc1").Range.Subdocuments.AddFromFile(m.lcDoc1)
    .Bookmarks("doc2").Range.Subdocuments.AddFromFile(m.lcDoc2)
    .Bookmarks("doc3").Range.Subdocuments.AddFromFile(m.lcDoc3)
    .ActiveWindow.View.Type = wdPrintView
 EndWith
 .Visible = .t.
endwith
I think master document approach would be better for preserving columns etc.
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