Solved

when making a custom shortcut or pop menu in word how can I break my menu options into different columns

Posted on 2013-01-27
4
279 Views
Last Modified: 2013-01-27
when making a custom shortcut or pop menu in word how can I break my menu options into different columns
my choices on the shortcut menu are to many to fit on the screen when displayed in a single column I would like to display my menu selctions inmutliple columns How do I do this
0
Comment
Question by:Dov_B
  • 2
  • 2
4 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 38824435
For a pop-up menu, I don't think you can show a multi-column layout.

What you could do, however, is use a CommandBarPopup instead of a CommandBarButton, to introduce a sub-level of menu options.
0
 

Author Comment

by:Dov_B
ID: 38824465
here is the code I got from a different expert that creates the overly long menu that wish to break into multiple columns
Sub ReplaceTextCommandbar()
    Dim ContextMenu As CommandBar
    Dim ctrl As CommandBarControl

    Dim synInfo As SynonymInfo
    Dim SynRange As Range
    Dim myRange As Range
    Dim aSynList() As String
    Dim idxSynList As Integer
    Dim strMessage As String
    Dim IdxMeaning As Integer
    Dim cbCtrlB As CommandBarButton
    Dim StrTemp As String

    ' Set ContextMenu to the Cell context menu.
    Set ContextMenu = Application.CommandBars("Text")

    ' Delete all controls
    For Each ctrl In ContextMenu.Controls
        ctrl.Delete
    Next ctrl


    Set SynRange = Selection.Range
    lngWordStart = SynRange.Words.First.Start
    lngWordEnd = lngWordStart + Len(Trim(SynRange.Words.First.Text))
    Set myRange = ActiveDocument.Range(lngWordStart, lngWordEnd)
    Set synInfo = myRange.SynonymInfo
    If synInfo.MeaningCount = 0 Then
        Set cbCtrlB = CommandBars("Text").Controls.Add(msoControlButton, , , 1)
        With cbCtrlB
            .Caption = "(No proposition)"
            .Enabled = False
        End With
    Else
        For IdxMeaning = 1 To UBound(synInfo.MeaningList)
            aSynList = synInfo.SynonymList(IdxMeaning)
            Set cbCtrlB = CommandBars("Text").Controls.Add(msoControlButton)
            With cbCtrlB
                .Caption = "Meaning: " + _
                    synInfo.MeaningList(IdxMeaning) + _
                    " (" + GetPartOfSpeech(synInfo.PartOfSpeechList(IdxMeaning)) + ")"
                .Enabled = False
                .BeginGroup = True
            End With
            For idxSynList = 1 To UBound(aSynList)
                Set cbCtrlB = CommandBars("Text").Controls.Add(msoControlButton)
                With cbCtrlB
                    .Caption = aSynList(idxSynList)
                    .OnAction = "ReplaceText"
                    .Parameter = aSynList(idxSynList)
                    If idxSynList = 1 Then .BeginGroup = True
                End With
            Next idxSynList
        Next IdxMeaning
    End If
'
End Sub

Open in new window

If need be I can also supply the subroutines and functions this macro calls
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 38824655
You could try this.  It creates a CommandBarPopup for each meaning, and as you select each one you get an additional list of the various synonyms for that meaning.



Sub ReplaceTextCommandbar()
    Dim ContextMenu As CommandBar
    Dim ctrl As CommandBarControl

    Dim synInfo As SynonymInfo
    Dim SynRange As Range
    Dim myRange As Range
    Dim aSynList() As String
    Dim idxSynList As Integer
    Dim strMessage As String
    Dim IdxMeaning As Integer
    Dim cbCtrlB As CommandBarButton
    Dim StrTemp As String
    Dim lngWordStart As Long, lngWordEnd As Long
    Dim cbp As CommandBarPopup
    
    ' Set ContextMenu to the Cell context menu.
    Set ContextMenu = Application.CommandBars("Text")

    ' Delete all controls
    For Each ctrl In ContextMenu.Controls
        ctrl.Delete
    Next ctrl


    Set SynRange = Selection.Range
    lngWordStart = SynRange.Words.First.Start
    lngWordEnd = lngWordStart + Len(Trim(SynRange.Words.First.Text))
    Set myRange = ActiveDocument.Range(lngWordStart, lngWordEnd)
    Set synInfo = myRange.SynonymInfo
    If synInfo.MeaningCount = 0 Then
        Set cbCtrlB = ContextMenu.Controls.Add(msoControlButton, , , 1)
        With cbCtrlB
            .Caption = "(No proposition)"
            .Enabled = False
        End With
    Else
        For IdxMeaning = 1 To UBound(synInfo.MeaningList)
            aSynList = synInfo.SynonymList(IdxMeaning)
            Set cbp = ContextMenu.Controls.Add(msoControlPopup)
            With cbp
                .Caption = "Meaning: " + _
                    synInfo.MeaningList(IdxMeaning) + _
                    " (" + GetPartOfSpeech(synInfo.PartOfSpeechList(IdxMeaning)) + ")"
                .Enabled = True
                .BeginGroup = True
            End With
            For idxSynList = 1 To UBound(aSynList)
                Set cbCtrlB = cbp.Controls.Add(msoControlButton)
                With cbCtrlB
                    .Caption = aSynList(idxSynList)
                    .OnAction = "ReplaceText"
                    .Parameter = aSynList(idxSynList)
                End With
            Next idxSynList
        Next IdxMeaning
    End If
    
    ContextMenu.ShowPopup
    
End Sub

Open in new window

0
 

Author Closing Comment

by:Dov_B
ID: 38824839
is it possible for you to give me the code that would display all the definitions simoultaneously in different columns if not with a vba menu but with an ahk menu instead?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now