|
-
Jul 30th, 2006, 11:49 AM
#1
Thread Starter
Lively Member
VBA WORD: readings words setting bookmarks ?
Hello, this is my very first VB program and i have a word document that contains certan pre-marked items, ie i put these a "<:" ":>" symbols around the items, and i'm trying to create a program that will recognize these symbols and automatically create a bookmark with what is in between these symbols.
The code seems to put the correct name in the bookmark list, but when i try to manually create a hyperlink to that bookmark, it doesn't jump to that bookmark location as expected and i realize that i probably need to use some special word(method) to capture the symbol and word's actual location and then apply the bookmark to that exact location does that sound like what i need please?
Any pointers would be appreciated! Thanks very much!
Sub ReadWord
Dim SingleWord As String
Dim pre3 As String
Dim pre2 As String
Dim pre1 As String
For Each aword In ActiveDocument.Words
' Range wr = aword.Item
SingleWord = Trim(LCase(aword))
pre3 = pre2
pre2 = pre1
pre1 = aword
'MsgBox (" 3/" + pre3 + " 2/" + pre2 + " 1/" + pre1)
If pre3 = "<:" And pre1 = ":>" Then
'ActiveDocument.Bookmarks.Add pre2
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:=pre2
End With
End If
Next aword
End Sub
-
Jul 30th, 2006, 01:11 PM
#2
Thread Starter
Lively Member
Re: VBA WORD: readings words setting bookmarks ?
Ok i think this works okay if i type it in like this:
...Name:="test name", but not when i use a variable name, pre2 as so:
...Name:=pre2
So i quess my new question is how to use a variable name, pre2, instead of a
literal name, "test_name" as a way to assign a name to the Name variable.
Thanks again!
BobK
-
Jul 30th, 2006, 01:55 PM
#3
Thread Starter
Lively Member
Re: VBA WORD: readings words setting bookmarks ?
ok got it, thanks for reviewing!
With ActiveDocument.Bookmarks
.Add pre2, Selection.Range
End With
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
|