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
278 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
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 …

708 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

18 Experts available now in Live!

Get 1:1 Help Now