Cindy said:
You don't really give us enough information to go on (such as, the
code you're using).
However, I can suggest another approach that doesn't use bookmarks,
and will avoid addressing the header/footer region directly in your
code. Create a document Variable (look up VARIABLE in Word's VBA
help) and put the information into that. Insert in the header a
DocVariable field (Insert/Fields) that references this variable.
Cindy Meister
Thanks for responding Cindy and I don't think the Access code has much to do
with this as it works for the 27 other bookmarks in the document. I did
include a scaled down version of it below. The only bookmark affecting it is
the header bookmark. If I take it out, no problem put it back and it will
print the first time then I need to close the Access app and restart it to
print another copy. I did look at the Microsoft KB for this and found a
macro work around that just didn't work with my version (is was for a 2000
version, I'm using 2002). I will check out the document variable approch
and see if that works. I will still have to pass the data from Access to
Word.
Private Sub MergeButton_Click()
On Error GoTo MergeButton_Err
Dim objWord As Word.Application
'Start Microsoft Word.
Set objWord = CreateObject("Word.Application")
With objWord
'Make the application visible.
.Visible = True
'Open the document.
.Documents.Open (Application.CurrentProject.path &
"\Lease\Lease.doc")
'Move to each bookmark and insert text from the form.
The next 2 lines are to the header
'ActiveDocument.Bookmarks("lease").Select
'.Selection.Text = ([fsubTenantLeases].Form![LedgerID])
I have remove some of these to just save some space as it really doesn't
matter how many as these are all in the body and work fine.
.ActiveDocument.Bookmarks("ax1").Select
.Selection.Text = (CStr(FORMS![frmTENANTS]![AccountName]))
.ActiveDocument.Bookmarks("ax2").Select
.Selection.Text =
(CStr(Trim(FORMS![frmTENANTS]![fsubTenantAddress].Form![Address1])))
.ActiveDocument.Bookmarks("ax3").Select
.Selection.Text =
(CStr(Trim(FORMS![frmTENANTS]![fsubTenantAddress].Form![Address2])))
.. End With
'Print the document in the foreground so Microsoft Word will not close
'until the document finishes printing.
objWord.ActiveDocument.PrintOut Background:=False
'Close the document without saving changes.
objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
'Quit Microsoft Word and release the object variable.
objWord.Quit
Set objWord = Nothing
Exit Sub
MergeButton_Err:
'If a field on the form is empty, remove the bookmark text, and
'continue.
If Err.Number = 94 Then
objWord.Selection.Text = ""
Resume Next
End If
Exit Sub
End Sub