+ Reply to Thread
Results 1 to 2 of 2

custom menu items not responding after initial save

  1. #1
    MAB
    Guest

    custom menu items not responding after initial save

    After saving a workbook created from a template with marcos (BOM
    importation), the custom right click menu items I create error out. It seems
    if you don't save the file using the default name then the menu error occurs.


  2. #2
    MAB
    Guest

    RE: custom menu items not responding after initial save

    Here's the code for the menu creation

    Private WithEvents xlApp As Excel.Application

    Private Sub Class_Initialize()
    Set xlApp = Excel.Application
    End Sub

    Private Sub xlApp_SheetBeforeRightClick(ByVal Sh As Object, _
    ByVal Target As Range, Cancel As Boolean)

    'Add or remove Hyperlink menu items based on whether or not Hyperlink(s)
    are selected

    Dim oCtrl As CommandBarControl
    Dim oBtn As CommandBarControl
    Dim bMenusExist As Boolean
    Dim bHyperlinksExist As Boolean

    For Each oCtrl In Application.CommandBars("Cell").Controls
    If oCtrl.Caption = "Copy Hyperlinked Docs To..." Then
    bMenusExist = True
    Exit For
    End If
    Next

    bHyperlinksExist = Target.Hyperlinks.Count > 0

    If bHyperlinksExist And Not bMenusExist Then
    Set oCtrl =
    Application.CommandBars("Cell").Controls.Add(Type:=msoControlButton, _
    Temporary:=True)
    oCtrl.Caption = "Copy Hyperlinked Docs To..."
    oCtrl.OnAction = "CopyHyperlinkedDocsTo"

    Set oCtrl =
    Application.CommandBars("Cell").Controls.Add(Type:=msoControlButton, _
    Temporary:=True)
    oCtrl.Caption = "Zip && Email Hyperlinked Docs..."
    oCtrl.OnAction = "ZipAndEmailHyperlinkedDocs"
    ElseIf Not bHyperlinksExist Then
    For Each oCtrl In Application.CommandBars("Cell").Controls
    If oCtrl.Caption = "Copy Hyperlinked Docs To..." Then
    oCtrl.Delete
    ElseIf oCtrl.Caption = "Zip && Email Hyperlinked Docs..." Then
    oCtrl.Delete
    End If
    Next
    End If
    End Sub

    "MAB" wrote:

    > After saving a workbook created from a template with marcos (BOM
    > importation), the custom right click menu items I create error out. It seems
    > if you don't save the file using the default name then the menu error occurs.
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1