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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
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…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

829 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