Results 1 to 5 of 5

Thread: [VBA Word] Drop down Menu and Content Repetition

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    On top of Auto Text, if you would like button selection, you can create a few sets of macros and place them on the Ribbon. A macro example for this would be:

    Sub oTrusts()
    '
    Dim oDoc as ActiveDocument
    '
    Select Case Control.ID
    'Inserts selection of trust type 1 or trust type 2 after the mouse cursor.
    '
    Case Btn1
    oDoc.BuildingBlockTypes(wdTypeAutoText).Categories("Legal").BuildingBlocks("Trust1").Insert Selection.Range
    '
    Case Btn2
    oDoc.BuildingBlockTypes(wdTypeAutoText).Categories("Legal").BuildingBlocks("Trust2").Insert Selection.Range
    '
    Case Else
    'Do nothing
    End Sub
    Now, the trick is to add the drop-down using Custom UI Editor. With some simple XML, you can create a new tab on the ribbon that can contain several groups and buttons/dropdown menus.

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="RibbonControl.Onload">
      <ribbon>
        <tabs>
          <tab id="CustomTab1" label="LEGAL AID">
            <group id="CustGrp1" label="GROUP 1" >
               <gallery id="Gallery1" size="large" imagemso="">
                <button id="Btn1" label="Trust Wife" size="large" image="LegalStyle1" onAction="RibbonControl.MyBtnMacro" />
                <button id="Btn1" label="Trust No One" size="large" image="LegalStyle2" onAction="RibbonControl.MyBtnMacro" />
            </group>
           </tab>
        </tabs>
      </ribbon>
    You can import images for the buttons using the Custom UI Editor. With a bit of research you should have it down in no time. Feel free to ask more questions here if you have any.

    Edit: Also, there is code to add a quick part to a specific gallery and category.

    Sub CreateLegalQuickPart()Dim oRng As Word.Range
    Dim oTmp As Template
    Dim oQP as String
    
    
    'Prompts for a name for the Quick Part
    Set oQP = InputBox("Name of Quick Part:", "Prompt!")  
    
    
    'Place the name of your template within the quotes
      sPath = Options.DefaultFilePath(wdUserTemplatesPath) & "LegalTemplate.dotm" 
      Set oTmp = Templates(sPath)
      oTmp.BuildingBlockEntries.Add _
        Name:=oQP, Type:=wdTypeQuickParts, Category:="Legal", _
        Range:=oRng, InsertOptions:=wdInsertContent
    lbl_Exit:
      Exit Sub
    End Sub
    Last edited by MacroWizard; 11-30-2015 at 08:56 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •