I am updating an MS Word document from MS Access, below is my code. The
following statement works when I have a reference to the VBA Microsoft Word
Object Library 10.0 in Access set, but I receive Error no: 5101 “This
bookmark does not exist”.
when I uncheck the Microsoft Word Object Library 10.0 reference in Access
VBA: (reference ** in code)
appWord.Selection.Goto What:=wdGoToBookmark, Name:="IIIA1"
I wish to use late-binding in this application so it will work more
universally. What is wrong with this statement?
Also, will the next 2 statements work without modification?
Is there a source for MS Word error no. descriptions? Also, where can I
read more about Word objects—what they are and how to use them?
Thanks for your assistance!!
Alan
ACCESS CODE FOLLOWS:
‘DECLARE VARS
Dim appWord As Object
Dim Docs As Object
‘OPEN MW WORD AND DOCUMENT
strSched = "C:\Templates\Document.dot
Set appWord = GetObject(, "Word.Application")
Set Docs = appWord.Documents
Docs.Add strSched
‘GOTO BOOKMARK AND HIDE TEXT
** appWord.Selection.Goto What:=wdGoToBookmark, Name:="IIIA1"
appWord.Selection.MoveRight Unit:=wdCharacter, Count:=198,
Extend:=wdExtend
appWord.Selection.Font.Hidden = True
‘QUITE MS WORD AND RESET DIM VARS
appWord.Quit
Set appWord = Nothing
Set Docs = Nothing
>I am updating an MS Word document from MS Access, below is my code. The
> following statement works when I have a reference to the VBA Microsoft
[quoted text clipped - 8 lines]
> I wish to use late-binding in this application so it will work more
> universally. What is wrong with this statement?
When you use late binding, Word's constants are no longer known to the
application and you have to define them for yourself.
Include the following line in your routine
Const wdGoToBookmark = -1
> Also, will the next 2 statements work without modification?
>
[quoted text clipped - 20 lines]
> Set appWord = Nothing
> Set Docs = Nothing
Similarly, with late binding the Word constants wdCharacter and wdExtend are
not predefined. They need to be explicitly defined as follows
Const wdCharacter = 1
Const wdExtend = 1
> Is there a source for MS Word error no. descriptions?
In the Word VBA Help file there is a topic titled Trappable Errors. If you
loo up the Error function in the VBA help, it is one of the pages listed in
the "See Also" link.
> Also, where can I
> read more about Word objects—what they are and how to use them?
The Word VBA Help file is the place. A very good initial overview can also
be found here
Getting To Grips With VBA Basics In 15 Minutes
http://word.mvps.org/FAQs/MacrosVBA/VBABasicsIn15Mins.htm

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Al - 03 Jan 2005 20:47 GMT
Thanks Jonathan (&Helmut)
Setting those parameters worked.
So now my question is how did you know what to set the parameters to? Is
there documentation somewhere with the available settings for what: (-1 for
bookmark), Unit: (1 for character), Extend:(1 for ?)
> >I am updating an MS Word document from MS Access, below is my code. The
> > following statement works when I have a reference to the VBA Microsoft
[quoted text clipped - 61 lines]
> Getting To Grips With VBA Basics In 15 Minutes
> http://word.mvps.org/FAQs/MacrosVBA/VBABasicsIn15Mins.htm
Jonathan West - 03 Jan 2005 22:33 GMT
> Thanks Jonathan (&Helmut)
>
[quoted text clipped - 4 lines]
> for
> bookmark), Unit: (1 for character), Extend:(1 for ?)
Hi Al,
When working with early binding or within VBA itself, you get prompted for
the constant names.
To get the values, open the VBA editor in the application, or alternatively
temporarily set an early binding reference again, and then just get the
value of the constant to print out in the immediate window.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Al - 04 Jan 2005 03:37 GMT
Thanks,
That worked. Now I know what the values are and how to see what they are.
> > Thanks Jonathan (&Helmut)
> >
[quoted text clipped - 13 lines]
> temporarily set an early binding reference again, and then just get the
> value of the constant to print out in the immediate window.
Hi Al,
I'd say, if you use late binding,
access doesn't know word constants like wdGoToBookmark.
Same applies to wdCharacter.
You may use the corresponding values instead.
wdGoToBookmark= -1
wdCharacter= 1
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/