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
285 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
[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
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
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…

628 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