Solved

i need a macro to add 'insert bookmark' to my right click menu

Posted on 2004-10-13
10
318 Views
Last Modified: 2008-05-09
well the title says it all really, could someone please write me a macro that will add the insert bookmark function to the right click menu in Word 2002.  i want to be able to save the macro in the normal template so that it will be available in all word docs.

thanks,

nick
0
Comment
Question by:nick_harambee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 9

Expert Comment

by:Shahid Thaika
ID: 12299414
Does opening the Main template (Normal.dot) and then saving the customized template help, rather that making a macro and running it every time.
0
 

Author Comment

by:nick_harambee
ID: 12299431
i have a few macros in my normal template that work fine in all word docs (and i am clear on how to do this), what i need is the specific macro for adding insert bookmark to the right click menu,

nick.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 12299514
The context-sensitive right-click pop-up is not exposed for modification. You will need a button if you want to make it a bit quicker to add bookmarks.
0
Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

 

Author Comment

by:nick_harambee
ID: 12299542
oh, well someone recently sent me a macro for adding 'paste unformatted text' to the right click menu, one macro for tables, and one for plain documents, and this works fine...so i figured this would be possible for other functions.

nick.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 12299616
Well it's not the first time I've been completely wrong and it won't be the last. Perhaps you could post or point to it and we can adapt it for your new purpose.
0
 

Author Comment

by:nick_harambee
ID: 12299655
here is the macro that adds 'paste unformatted text' to the right click menu for both table and standard document.  maybe you could adapt it.  i won't be needing to insert bookmarks into tables so the macro should hopefully be simpler....

Private Sub Document_Open()
   
    Call AddPasteSpecial

End Sub

Private Sub Document_New()
   
    Call AddPasteSpecial

End Sub
 
Sub AddPasteSpecial()

Dim cb              As CommandBar
Dim c               As CommandBarButton
   
    Set cb = Application.CommandBars("Table Text")
    Set c = cb.FindControl(, , "VBAxPasteSpec")
    If Not c Is Nothing Then
        c.Delete
    End If
    Set c = cb.Controls.Add(msoControlButton, , , 4, True)
    With c
        .Caption = "Paste Unformatted Text"
        .Style = msoButtonCaption
        .TooltipText = "Paste Special"
        .Tag = "VBAxPasteSpec"
        .OnAction = "PasteUnformattedText"
    End With
   
    Set cb = Application.CommandBars("Text")
    Set c = cb.FindControl(, , "VBAxPasteSpec")
    If Not c Is Nothing Then
        c.Delete
    End If
    Set c = cb.Controls.Add(msoControlButton, , , 4, True)
    With c
        .Caption = "Paste Unformatted Text"
        .Style = msoButtonCaption
        .TooltipText = "Paste Special"
        .Tag = "VBAxPasteSpec"
        .OnAction = "PasteUnformattedText"
    End With
   
End Sub

Sub PasteUnformattedText()

    Selection.PasteSpecial Link:=False, DataType:=wdPasteText, Placement:= _
        wdInLine, DisplayAsIcon:=False

End Sub
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 12299992
Thanks for that, I'd given up trying to find which command bar(s) were called by righ-click & and had decided that they weren't available at all.

Given that knowledge, the job was simple:

Option Explicit

Sub AddInsertBookMark()

Dim cb              As CommandBar
Dim c               As CommandBarButton
   
    Set cb = Application.commandbars("Table Text")
    Set c = cb.FindControl(, , "VBAxInsertBookmark")
    If Not c Is Nothing Then
        c.Delete
    End If
    Set c = cb.Controls.Add(msoControlButton, , , 4, True)
    With c
        .Caption = "Insert Bookmark"
        .Style = msoButtonCaption
        .TooltipText = "Insert Bookmark"
        .Tag = "VBAxInsertBookmark"
        .OnAction = "InsertBookmark"
    End With
   
    Set cb = Application.commandbars("Text")
    Set c = cb.FindControl(, , "VBAxInsertBookmark")
    If Not c Is Nothing Then
        c.Delete
    End If
    Set c = cb.Controls.Add(msoControlButton, , , 4, True)
    With c
        .Caption = "Insert Bookmark"
        .Style = msoButtonCaption
        .TooltipText = "Insert Bookmark"
        .Tag = "VBAxInsertBookmark"
        .OnAction = "InsertBookmark"
    End With
   
End Sub

Sub InsertBookmark()
Application.Dialogs(wdDialogInsertBookmark).Show
End Sub
0
 

Author Comment

by:nick_harambee
ID: 12300034
thanks graham

all seems to be working fine

i have accepted your answer

nick
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 12300250
T
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 12300259
Thanks Nick
For the interaction , the lesson, the points and the grade.
Cheers, Graham
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Printing A1 on A4 Printer 8 430
word 2016 1 34
Word 2010 assign Hyperlink to Sub code 5 39
vba - Word save error 11 35
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question