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 / July 2005

Tip: Looking for answers? Try searching our database.

Macro Code Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
caring4211 - 11 Jul 2005 17:47 GMT
I've written the following code and now I'm receiving a runtime error message
for "runtime error 5941" "the requested member of the collection does not
exist"

Can someone tell me what I'm doing wrong?  Here is the code:

Set vOne = ActiveDocument.FormFields("bkone").checkbox

       If vOne.Value = True Then
                ActiveDocument.Bookmarks("bkOneTwo").Select
       End If

Please advise!
Anne Troy - 11 Jul 2005 17:55 GMT
My guess is you deleted one of the bookmarks.
*******************
~Anne Troy

www.OfficeArticles.com
www.MyExpertsOnline.com

> I've written the following code and now I'm receiving a runtime error message
> for "runtime error 5941" "the requested member of the collection does not
[quoted text clipped - 9 lines]
>
> Please advise!
caring4211 - 11 Jul 2005 18:01 GMT
Both of the bookmarks are still there.  Any other ideas?

> My guess is you deleted one of the bookmarks.
> *******************
[quoted text clipped - 17 lines]
> >
> > Please advise!
Dave Lett - 11 Jul 2005 18:34 GMT
Hi,

You can test if the bookmarks exist in code with something like the
following:

MsgBox "bkOneTwo exists:" & vbTab &
ActiveDocument.Bookmarks.Exists(Name:="bkOneTwo")
MsgBox "bkone exists:" & vbTab &
ActiveDocument.Bookmarks.Exists(Name:="bkone")

Also, to really help with the issue, it might be useful to know which line
your routine is raising the error.

HTH,
Dave

> Both of the bookmarks are still there.  Any other ideas?
>
[quoted text clipped - 20 lines]
>> >
>> > Please advise!
Jean-Guy Marcil - 11 Jul 2005 18:44 GMT
caring4211 was telling us:
caring4211 nous racontait que :

> I've written the following code and now I'm receiving a runtime error
> message for "runtime error 5941" "the requested member of the
[quoted text clipped - 7 lines]
>                 ActiveDocument.Bookmarks("bkOneTwo").Select
>        End If

On which line does the debugger stops?

Do you have multiple documents opened at the same time? If so, do not use
ActiveDocument, it may be pointing to the wrong document. Use Document
object variables instead:

Dim sourceDoc As Document
Dim vOne As CheckBox
Set sourceDoc = Documents("Document1") 'Actual name of document

Set vOne = sourceDoc.FormFields("bkone").CheckBox

If vOne.Value = True Then
        sourceDoc.FormFields("bkOneTwo").Select
End If

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

caring4211 - 11 Jul 2005 18:52 GMT
The debugger stops on the first line.  I only have one document opened but
I'll try renaming it to the document's actual name.

Lynda

> caring4211 was telling us:
> caring4211 nous racontait que :
[quoted text clipped - 26 lines]
>          sourceDoc.FormFields("bkOneTwo").Select
> End If
Jean-Guy Marcil - 11 Jul 2005 20:01 GMT
caring4211 was telling us:
caring4211 nous racontait que :

> The debugger stops on the first line.  I only have one document
> opened but I'll try renaming it to the document's actual name.

If you have that error on
   Set vOne = ActiveDocument.FormFields("bkone").checkbox
this means there are no formfields named "bkone".

Double click on your formfield in design mode to access its properties, look
at the Bookmark field in the properties dialog and make sure it is indeed
"bkone".

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

caring4211 - 11 Jul 2005 21:17 GMT
Thank you so much.  That was exactly it!  I didn't realize that they had to
have the "bk" portion before the "one" or "onetwo" in the properties.  It's
working now!!!

THANK YOU!

Lynda

> caring4211 was telling us:
> caring4211 nous racontait que :
[quoted text clipped - 9 lines]
> at the Bookmark field in the properties dialog and make sure it is indeed
> "bkone".
 
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.