List all Bookmarks in a Protected Form

L

Leonard

Hello everyone.

I have a protected form that is filled out by various users. I would like
to be able to go to the end of each completed document where there is an
unprotected continuous section and click a MACROBUTTON which will run a macro
that will display the "text only" of each bookmark in the document. Each
bookmark text would be listed in a separate paragraph in the order that they
appear on the protected form.

Thanks.
 
G

Greg Maxey

Leonard,

Assuming it is a two section document and section 2 is currently blank, you
could use something like this:

Sub ScratchMacro()
Dim pBkm As Bookmark
Dim pString As String
Dim myRng As Range
Set myRng = ActiveDocument.Sections(2).Range
For Each pBkm In ActiveDocument.Bookmarks
pString = pBkm.Range.Text
With myRng
.InsertBefore Right(pString, Len(pString) - 9) & vbCr
End With
Next
End Sub
 
L

Leonard

Hello Mr. Greg Maxey. Thanks for your assistance. I tried your macro but
it disn't work for me. The very last Section in my protected document is 33
(which I left unprotected). I changed "Set myRng =
ActiveDocument.Sections(2).Range" to read "Set myRng =
ActiveDocument.Sections(33).Range", but the macro didn't do a thing, i.e., it
didn't list all the bookmark text in sequence.
 
G

Greg Maxey

Leonard,

If you have 32 protected sections then you will need to have a 33rd
unprotected section to receive the data.

Sub ScratchMacro()
Dim pBkm As Bookmark
Dim pString As String
Dim myRng As Range
Set myRng = ActiveDocument.Sections(33).Range
For Each pBkm In ActiveDocument.Bookmarks
pString = pBkm.Range.Text
With myRng
.InsertBefore Right(pString, Len(pString) - 9) & vbCr
End With
Next
End Sub
 

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