|
-
Sep 28th, 2004, 06:49 PM
#1
Thread Starter
New Member
WORD form/VBA issue - Urgent help req.
Hi all - being a newbie I'll try and be quick. I'm having trouble debuging VBA in Word (2002 SP2).
In a nutshell I'm trying to delete a bookmark - the bookmark is not being deleted and yet even in debug mode and stepping a line at a time I can see no error or issue.
I'd really appreciate any suggestions as it is doing my head in - I've surfed the net and can't find any suggestions as well as reading the help, and two books. How can something so simple be so sdifficult to resolve?
In debug mode all lines are peformed, but the bookmark remains!
Cheers
Colin.
Sub checktest()
On Error Resume Next
If ThisDocument.Bookmarks.Exists("text") Then
MsgBox "found test1 bookmark"
ActiveDocument.Bookmark("text").Range.Delete
MsgBox "after delete"
End If
End Sub
-
Sep 28th, 2004, 11:19 PM
#2
Thread Starter
New Member
It always happens - just when you ask for help you get one more last idea and what do you know - I was creating the bookmark incorrectly. Just a shame that VB allows this without any form of warning - it could find it but not delete it.
Cheers anyway.
-
Sep 29th, 2004, 08:44 AM
#3
Lively Member
For future reference...
To keep it "neat", check for the existence of the bookmark first and then delete it. You shouldn't need to use the range object when deleting bookmarks.
To delete a bookmark in Word use the following (VB):
VB Code:
If .ActiveDocument.Bookmarks.Exists("BookmarkName") = True then
.ActiveDocument.Bookmarks("BookmarkName").Delete
End if
Note -- in VBA you don't need the period before ActiveDocument
Good luck!
Mary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|