Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Joe Cilinceon
 
Posts: n/a
Default Bookmarks in Header/Footer

What I have is a Lease done in Word XP with about 30 bookmarks in the body
of the form. This all works perfectly from my Access XP application. Now a
problem arises when I add a book mark to the header, I'm trying to add a
lease number to the header. Well as long as the bookmark is in the main body
no problem, I call the routine as many times as I like. However with the
bookmark in the header it works the first time it is called and the second
time hangs on the header bookmark. I restart the application and it will
print fine again. Is there some trick or technique to using bookmarks in the
header with Word 2002/XP.

--

Joe Cilinceon



  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Cindy M -WordMVP-
 
Posts: n/a
Default Bookmarks in Header/Footer

Hi Joe,

What I have is a Lease done in Word XP with about 30 bookmarks in the body
of the form. This all works perfectly from my Access XP application. Now a
problem arises when I add a book mark to the header, I'm trying to add a
lease number to the header. Well as long as the bookmark is in the main body
no problem, I call the routine as many times as I like. However with the
bookmark in the header it works the first time it is called and the second
time hangs on the header bookmark. I restart the application and it will
print fine again. Is there some trick or technique to using bookmarks in the
header with Word 2002/XP.

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
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Joe Cilinceon
 
Posts: n/a
Default Bookmarks in Header/Footer

Cindy M -WordMVP- wrote:
Hi Joe,


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


--

Joe Cilinceon



  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Cindy M -WordMVP-
 
Posts: n/a
Default Bookmarks in Header/Footer

Hi Joe,

I don't think the Access code has much to do
with this

Yes, as a matter of fact it does. You're doing what I
suspected - trying to jump to the bookmarks, rather than
manipulate the objects. And that simply doesn't work well
with headers and footers.

'ActiveDocument.Bookmarks("lease").Select
'.Selection.Text =
([fsubTenantLeases].Form![LedgerID])

Do this, instead:

Dim doc as word.Document
Set doc =
.Documents.Open(Application.CurrentProject.path _
& "\Lease\Lease.doc")
doc.Bookmarks("lease").Range.Text = _
([fsubTenantLeases].Form![LedgerID])

You'll find it's also rather faster and easier on the
users' eyes :-)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)

  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Joe Cilinceon
 
Posts: n/a
Default Bookmarks in Header/Footer

Thanks again Cindy I'll give it a try. I'm also messing with Ref for a few
of these. Some of the stuff at the top of the document, such as Rent, Late
Fee, Adm. Fee charges and such repeat in the last paragraph of the document.
I'm trying to get Ref bookmark's name to work but so far all I get is an
error in my paragraph. All of this is just to fine tune a working
application.

Oh and the header/footer I fixed with the macro from MS in the Word document
itself. This is the only document created in real time from an open set of
Access forms. We print at the time we rent a storage unit.

--

Joe Cilinceon


Cindy M -WordMVP- wrote:
Hi Joe,

I don't think the Access code has much to do
with this

Yes, as a matter of fact it does. You're doing what I
suspected - trying to jump to the bookmarks, rather than
manipulate the objects. And that simply doesn't work well
with headers and footers.

'ActiveDocument.Bookmarks("lease").Select
'.Selection.Text =
([fsubTenantLeases].Form![LedgerID])

Do this, instead:

Dim doc as word.Document
Set doc =
.Documents.Open(Application.CurrentProject.path _
& "\Lease\Lease.doc")
doc.Bookmarks("lease").Range.Text = _
([fsubTenantLeases].Form![LedgerID])

You'll find it's also rather faster and easier on the
users' eyes :-)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
troubleshooting hyperlink bookmarks Kat Page Layout 2 August 29th 05 12:57 PM
First page header/footer appearing on second page as well! JoshMandel Page Layout 4 July 25th 05 06:25 PM
Inserting letter text causes header/footer to disappear dunkafife Page Layout 3 June 21st 05 06:27 PM
Bookmarks appearing in HTML Format document links AndyBear Microsoft Word Help 3 June 1st 05 02:45 PM
Add bookmarks in header/footer Kind writer/user/programmer Microsoft Word Help 1 December 7th 04 07:55 PM


All times are GMT +1. The time now is 06:28 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"