Printing/showing bookmarks - again

  • Thread starter Thread starter Sandra
  • Start date Start date
S

Sandra

Thanks to macropod who replied to my original post on Sept
10. You listed a macro which wouldn't work for me. When I
ran it, it would stop at one of hte lines and say "Compile
error: Invalid use of property." I'm not very good at
writing programs so perhaps I'm doing something very
simple wrong.

For everyone else - please respond! My original problem is
that I'm writing a program to pop up a box and then insert
text typed in each box into a document. What I did was
that I created the document, placed bookmarks at each spot
I wanted to insert the text, then wrote a program that,
when you press "Ok", it will insert the text at the
bookmark points. Everything is working except for the
first bookmark on the page, for some reason it won't
insert the text there. I've checked every other
possibility, and I'm down to checking bookmarks. However,
once placed you cannot see where each bookmark is in the
document. So I'm stuck. Can anyone please help me?

Sandra
 
Hi Sandra,

Typo. Try this:

Sub ListBkMrks()
Dim oBkMrk As Bookmark, oBmk As Variant
If ActiveDocument.Bookmarks.Count > 0 Then
For Each oBkMrk In ActiveDocument.Bookmarks
With Selection
.EndKey Unit:=wdStory
.InsertAfter vbCrLf
.InsertAfter oBkMrk.Name & " "
.EndKey Unit:=wdStory
oBmk = ActiveDocument.Fields.Add(Range:=Selection.Range, _
Text:=oBkMrk.Name, PreserveFormatting:=False)
End With
Next oBkMrk
End If
End Sub

Cheers
 
Hi Sandra,

Now that you've supplies some additional details on what you are
trying to accomplish there are some other options you can look into.
:-)

1. Utilize Fill-In fields which work without Bookmarks. Place your
cursor where the text needs to be inserted, go to Insert/Field and
select "Fill-In".

2. Since you already have your Bookmarks in place why not replace the
various prompts and use a UserForm instead? This allows the user to
fill in everything in one form and you have the ability to validate
the entries.

For some UserForm basics take a look at:
http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm

Note the article doesn't cover information such as naming conventions
and more advanced features but it should be enough to get you started
in the general direction.

--
Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 
Back
Top