M
Marco
I’ve created a few functions and procedures in a template loaded via
options/file locations/start up to enable users in a workgroup to insert
letterheads and footers to new or pre-existing documents. The letterheads
and footers are stored in individual templates (though I’ve also tested with
plain .doc). In each of the templates, a continuous section break follows
each of the letterheads. The purpose of the section break is to preserve the
formatting of the destination document, since the letterheads are fairly
wide, and I don’. Version of Word is 2003.
While I was in the startup-to-be template, I created and tested the
functions and procedures to make all this happen. No problems. When I saved
it to the start up directory and restarted word to load from it, I ran into a
problem. When a letterhead is inserted now, the section break is no longer
continuous but causes a page break.
I’ve tried this a few different ways, but the end result is always the same.
Here’s a look:
Select Case intMethod
Case 1 ' FIELD EMPTY
Dim strIncludeText As String
strIncludeText = Replace(PathToTemplates, "\", "\\") &
strLetterhead
strIncludeText = "INCLUDETEXT """ & strIncludeText & """" & "
bmkLetterhead"
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
Text:=strIncludeText, PreserveFormatting:=True
Case 2 ' FIELD: INCLUDE TEXT
Dim strIncludeText As String
strIncludeText = Replace(PathToTemplates, "\", "\\") &
strLetterhead
strIncludeText = """" & strIncludeText & """" & " bmkLetterhead"
Selection.Fields.Add Range:=Selection.Range,
Type:=wdFieldIncludeText, _
Text:=strIncludeText, PreserveFormatting:=True
Case 3 ' INSERT FILE: Linked
Selection.InsertFile FileName:=strLetterhead,
Range:="bmkLetterhead", Link:=True
Case 4 ' INSERT FILE: Not Linked
Selection.InsertFile FileName:=strLetterhead,
Range:="bmkLetterhead", Link:=False
Case 5 ' COPY & PASTE
Documents.Open FileName:=strLetterhead,
ConfirmConversions:=False, _
ReadOnly:=True, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto,
XMLTransform:="", _
Visible:=False
Documents(strLetterhead).Bookmarks("bmkLetterhead").Select
Selection.Copy
Documents(strLetterhead).Close False
Selection.PasteAndFormat (wdPasteDefault)
End Select
One other thing that I tried was inserting the section break before
inserting the document. That also didn’t work. Here’s the code:
Selection.HomeKey Unit:=wdStory
Selection.InsertBreak Type:=wdSectionBreakContinuous
Selection.HomeKey Unit:=wdStory
My requirement is to actually insert the letterhead rather than link to it,
but I tried these other methods as alternatives hoping that one would work.
Any ideas what is causing this or how I can work around it?
options/file locations/start up to enable users in a workgroup to insert
letterheads and footers to new or pre-existing documents. The letterheads
and footers are stored in individual templates (though I’ve also tested with
plain .doc). In each of the templates, a continuous section break follows
each of the letterheads. The purpose of the section break is to preserve the
formatting of the destination document, since the letterheads are fairly
wide, and I don’. Version of Word is 2003.
While I was in the startup-to-be template, I created and tested the
functions and procedures to make all this happen. No problems. When I saved
it to the start up directory and restarted word to load from it, I ran into a
problem. When a letterhead is inserted now, the section break is no longer
continuous but causes a page break.
I’ve tried this a few different ways, but the end result is always the same.
Here’s a look:
Select Case intMethod
Case 1 ' FIELD EMPTY
Dim strIncludeText As String
strIncludeText = Replace(PathToTemplates, "\", "\\") &
strLetterhead
strIncludeText = "INCLUDETEXT """ & strIncludeText & """" & "
bmkLetterhead"
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
Text:=strIncludeText, PreserveFormatting:=True
Case 2 ' FIELD: INCLUDE TEXT
Dim strIncludeText As String
strIncludeText = Replace(PathToTemplates, "\", "\\") &
strLetterhead
strIncludeText = """" & strIncludeText & """" & " bmkLetterhead"
Selection.Fields.Add Range:=Selection.Range,
Type:=wdFieldIncludeText, _
Text:=strIncludeText, PreserveFormatting:=True
Case 3 ' INSERT FILE: Linked
Selection.InsertFile FileName:=strLetterhead,
Range:="bmkLetterhead", Link:=True
Case 4 ' INSERT FILE: Not Linked
Selection.InsertFile FileName:=strLetterhead,
Range:="bmkLetterhead", Link:=False
Case 5 ' COPY & PASTE
Documents.Open FileName:=strLetterhead,
ConfirmConversions:=False, _
ReadOnly:=True, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto,
XMLTransform:="", _
Visible:=False
Documents(strLetterhead).Bookmarks("bmkLetterhead").Select
Selection.Copy
Documents(strLetterhead).Close False
Selection.PasteAndFormat (wdPasteDefault)
End Select
One other thing that I tried was inserting the section break before
inserting the document. That also didn’t work. Here’s the code:
Selection.HomeKey Unit:=wdStory
Selection.InsertBreak Type:=wdSectionBreakContinuous
Selection.HomeKey Unit:=wdStory
My requirement is to actually insert the letterhead rather than link to it,
but I tried these other methods as alternatives hoping that one would work.
Any ideas what is causing this or how I can work around it?