+ Reply to Thread
Results 1 to 12 of 12

Need to access non-native menu commands in VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    12-27-2008
    Location
    Texas
    Posts
    7

    Need to access non-native menu commands in VBA

    Hi All,

    I have an interesting problem I have not been able to find any references to anywhere, so here I am....

    I'm using Excel 2003 that has a menu bar added by another program that interfaces with it (via DDE, as I understand it). The DLL's from the other program have no documentation and/or ability for me to connect to the particular drop-down menu command I'm using. It is a refresh command that re-imports stock market trade data because DDE drops trade messages.

    Anyway, I hope I've explained that clearly enough. I'm just trying to figure out how I can call the command for a non-native menu bar item. You can't record a macro to access it. Surely there is some way. Any other ideas?

    Thanks in advance.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Does this thing add an addin, or a reference in the VBE?

    rylo

  3. #3
    Registered User
    Join Date
    12-27-2008
    Location
    Texas
    Posts
    7
    No, neither unfortunately.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Andy Pope recently posted this code to list all command bar controls:
    Sub ListControlIDs()
        Dim oCBC    As CommandBarControl
        Dim iRow    As Long
        Dim iID     As Long
    
        On Error Resume Next
        For iID = 1 To 31308
            Set oCBC = Application.CommandBars.FindControl(ID:=iID)
            If Not oCBC Is Nothing Then
                iRow = iRow + 1
                Cells(iRow, 1).Select
                Cells(iRow, 1) = iID
                Cells(iRow, 2) = oCBC.Caption
                Cells(iRow, 3) = oCBC.Parent.Name
            End If
        Next
    End Sub
    Once you find it in the list, you can execute it. For example, type this in the Immediate window:
    Application.CommandBars.FindControl(ID:=1849).Execute
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    12-27-2008
    Location
    Texas
    Posts
    7
    Great idea, and very close, but no cigar.

    Here are the first few lines of what I get. #1 Sterling Trader Pro is actually the name of the menu bar that has the refresh command I need to access, but the actual command (nor the other commands in that menu bar) are listed anywhere in the list generated by that macro.

    1	Sterling Trader Pro	Worksheet Menu Bar
    2	&Spelling...	Standard
    3	&Save	Standard
    4	&Print...	Document
    18	&New...	Desktop
    19	&Copy	Standard
    21	Cu&t	Standard
    22	&Paste	Standard
    23	Open	Standard
    37	&Repeat Find	Edit
    47	Clear	Button
    106	&Close	File
    107	Forma&t Report...	PivotTable Context Menu
    108	&Format Painter	Standard
    109	Print Pre&view	Standard
    113	&Bold	Formatting
    114	&Italic	Formatting
    115	&Underline	Formatting
    120	Align &Left	Formatting
    121	Align &Right	Formatting

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    No further ideas, sorry.

    Have you contacted Sterling?

+ 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