B
Barry555
Hello,
I've coded an Access app to produce .doc letters in Word using a .dot file
with bookmarks. To aid the user who has to print off the resultant letters
(might be 100s) I copy each letter produced into a single MasterDoc file,
then the user just has one file to print. This is all fine except for two
problems:
1. The MasterDoc file doesn't inherit the layout/page setup settings (e.g.
margins) from the inserted letters.
2. There is a numbered list in the .dot file. As each resultant letter
gets added into MasterDoc, the numbered list (in the letter in MasterDoc, the
individual letters are fine) increments instead of starting from 1!
Some of the code is:
Set objMasterDoc = objWord.Documents.Add()
Set rst = ...
Do
Set objDoc = objWord.Documents.Add(strTemplate)
....
objDoc.SaveAs strLetterPath
objDoc.Close
With objMasterDoc.Application.Selection
.InsertFile FileName:=strLetterPath, ConfirmConversions:=False
.InsertParagraphAfter
.InsertBreak Type:=2 'wdSectionBreakNextPage
.Collapse Direction:=0 'wdCollapseEnd
End With
.MoveNext
Loop Until rst.EOF
To combat problem 1, could I (and if so how!) do:
Set objMasterDoc = objWord.Documents.Add(strTemplate)
and then use code to strip out all text, bookmarks and headers and footers.
As for problem 2, I don't have a clue!
Thanks,
Barry
I've coded an Access app to produce .doc letters in Word using a .dot file
with bookmarks. To aid the user who has to print off the resultant letters
(might be 100s) I copy each letter produced into a single MasterDoc file,
then the user just has one file to print. This is all fine except for two
problems:
1. The MasterDoc file doesn't inherit the layout/page setup settings (e.g.
margins) from the inserted letters.
2. There is a numbered list in the .dot file. As each resultant letter
gets added into MasterDoc, the numbered list (in the letter in MasterDoc, the
individual letters are fine) increments instead of starting from 1!
Some of the code is:
Set objMasterDoc = objWord.Documents.Add()
Set rst = ...
Do
Set objDoc = objWord.Documents.Add(strTemplate)
....
objDoc.SaveAs strLetterPath
objDoc.Close
With objMasterDoc.Application.Selection
.InsertFile FileName:=strLetterPath, ConfirmConversions:=False
.InsertParagraphAfter
.InsertBreak Type:=2 'wdSectionBreakNextPage
.Collapse Direction:=0 'wdCollapseEnd
End With
.MoveNext
Loop Until rst.EOF
To combat problem 1, could I (and if so how!) do:
Set objMasterDoc = objWord.Documents.Add(strTemplate)
and then use code to strip out all text, bookmarks and headers and footers.
As for problem 2, I don't have a clue!
Thanks,
Barry