General information
Category:
COM/DCOM and OLE Automation
You should break the document into sections. Something like this:
....
wdStory=6
wdSectionBreakNextPage=2
with oWord
.Selection.EndKey(wdStory)
.Selection.InsertBreak(wdSectionBreakNextPage)
.Selection.InsertFile(ANOTHER_DOC_FILE)
....
It should presrve the original format, I believe. Also you may adjust section properties if needed. Like:
...
with .ActiveDocument.Sections(1)
.Headers(wdHeaderFooterPrimary).Range.Text = "Header text"
.Footers(wdHeaderFooterPrimary).Range.Text = "Footer text"
endwith
with .ActiveDocument.Sections(2)
.Headers(wdHeaderFooterPrimary).Range.Text = "2 Header text"
.Footers(wdHeaderFooterPrimary).Range.Text = "2 Footer text"
endwith
....
Best Wishes
>Hi Everyone,
>I was recently given the task of allowing a client to make their own template coversheets & title pages in Word, and then appending these pages to my reports which are being written into word via automation. I have chosen to do this by opening their template, selecting all, copying and pasting into the new document (again, through code, not manually). The problem is that Word seems to use the font already selected in the destination document instead of the font that the copied text originally had.
>
>Now, I have looked at several things in word that I thought may fix this. PasteSpecial as RTF does not help. CopyFormat() does indeed copy formatting to be pasted on another piece of text using PasteFormat(), but there are multiple formattings in their selection and those functions can only use 1. I also tried setting oWord.options.smartCutPaste which SOUNDED like my solution, but I still cannot get the original formatting to come with the cut and paste. Any suggestions from the Automation gurus?
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only