Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2005

Tip: Looking for answers? Try searching our database.

Please help! Error 5101 Bookmark does not Exist--but it does

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Al - 03 Jan 2005 16:01 GMT
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
Jonathan West - 03 Jan 2005 16:13 GMT
>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.
Helmut Weber - 03 Jan 2005 16:29 GMT
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/

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.