version problems - getting error message from macro run in 2000

H

HBO

I have created a macro that runs fine in both XP and word 2002. My problem
is that when it was run on word 2000 the macro crashed at this bit of code:

Sub UpdateBookmark(BkMrkToUpdte as string, TxtToUse as string)
Dim BMRange As Range

***** this is the line it stopped at below
Set BMRange= ActiveDocument.Bookmarks(BKMrkToUpdte).Range
BMRange.Text = TxtToUse
ActiveDocument.Bookmarks.Add BkMrkToUpdte, BMRange
End Sub

This code works fine in XP which I have and 2002 which my boss runs however
when he tried to distribute it to another person with word 2000 it crashed
here, with the message "requested member of the collection does not exist".
Since I don't have 2000 I can not test this but was wondering if this is a
version problem. I am currently trying to figure out if the person has all
the documents that are associated with the macro since that might be the
problem, however it should have bombed when I opened those documents. Any
help or assistance with this is appreciated.
HBO
 
J

Jezebel

You would get the message if you ran the macro on a document that didn't
have the bookmark.
 
H

HBO

Thanks Jezebel, I didn't think it was a version problem with bookmarks.
It's just hard understanding what the problem is when it gets passed on
through 3 different people and then finally to me. Plus it's also hard to
debug something for someone with whom you have no communication. I was
thinking that myself, as I wrote it but I thought I should check anyways.
Thanks again.
HBO
 
N

Nick Hebb

Try:
If ActiveDocument.Bookmarks.Exists(BKMrkToUpdte) Then
Set BMRange= ActiveDocument.Bookmarks(BKMrkToUpdte).Range
BMRange.Text = TxtToUse
ActiveDocument.Bookmarks.Add BkMrkToUpdte, BMRange
Else
' Find location to insert bookmark
' Add the bookmark
End If


--Nick
 
W

Wendy

One big reason that will be contributing to your problem is the way that Word
2000 opens documents. It is very different to other versions as instead of
having one Word window with several documents open in it, Word 2000 will open
a separate window for each document. It's therefore very easy to end up in
the wrong document window i.e. not the one with the bookmark!

Where possible, activate the relevant document first before performing any
actions. Also, try searching for MDI (multiple document interface) to find
out more.

Good luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top