Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

Finding a bookmark with a macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
EEvans - 29 Mar 2006 16:03 GMT
I need to find a way to locate a bookmark's index number via a macro.  
Currently I use, Dialogs(wdDialogInsertBookmark).Show to allow the user to
select the desired bookmark, then they have to click the Goto button.  I can
then get the index.  The problem is with
Dialogs(wdDialogInsertBookmark).Show, I can not disable the Delete button, if
the user clicks Delete rather than Goto the macro errors out.
Is there a way to display a dialog box, or something else, that will allow
the user to select a bookmark from a list, and then I be able to read the
index for that bookmark?
Greg - 29 Mar 2006 16:38 GMT
You could create a user form with a ListBox to list the bookmarks and a
command button.

Code something like this should do:

Private Sub CommandButton1_Click()
Dim pName As String
pName = Me.ListBox1.Text
MsgBox ActiveDocument.Bookmarks(pName).Range.BookmarkID
End Sub
Private Sub UserForm_Initialize()
Dim oBkm As Bookmark
For Each oBkm In ActiveDocument.Bookmarks
 Me.ListBox1.AddItem oBkm.Name
Next
End Sub
EEvans - 30 Mar 2006 23:01 GMT
I had thought about something like that, but I don't want to create another
user form.  This program is for mutiple users and some would have problems
with adding the form to thier documents.  Is there a way to add the form
automatically?  If not, is ther another way to list all of the bookmarks so
that the user can select one from the list?  

> You could create a user form with a ListBox to list the bookmarks and a
> command button.
[quoted text clipped - 12 lines]
> Next
> End Sub
Russ - 08 May 2006 02:43 GMT
> I had thought about something like that, but I don't want to create another
> user form.  This program is for mutiple users and some would have problems
> with adding the form to thier documents.  Is there a way to add the form
> automatically?

The normal.dot is left as pristine as possible for the user to adjust.

The way you add a form automatically is make it part of another global
template or add-in which means the other template is placed in the Microsoft
Office 'Startup' folder (locate by opening MacWord Preferences or WinWord
Tool:Options, tab: File Locations). Then any vba code and 'extra' forms,
menus, toolbars, etc. are automatically available to the user when Word is
started. The user won't be able to alter the global template parts unless he
finds and opens the global template in Word as a document or uses the
'Organizer' to move parts of the global template into his normal.dot
template.
The add-ins are also added by the menu Tools:Templates and Add-Ins... and
can be temporarily disabled anytime by unchecking them via that same menu
choice dialog that appears.

> If not, is ther another way to list all of the bookmarks so
> that the user can select one from the list?
[quoted text clipped - 15 lines]
>> Next
>> End Sub

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID <-- fix this before replying

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.