vba to set templates location RRS feed

  • Question

  • I am customizing the backstage in word with a new tab via the xml file and some vba in a module

    I created a docm, opened the xml file with custom UI editor and added my xml

    My xml file works great and puts 5 buttons and 5 combox boxes on my tab. Each combo box is populated with 9 entires which are template types. So far I have figured out how to open a dialogue box that is opening up at a network location that holds templates when an OnChange event happens with the combo box.  I tried using wdDialogFileNew which works great however it opens the templates dialogue box with only local templates, the same as clicking file>new>my templates.
    Can anyone tell me how to code it so that:
    I can use the wdDialogFileNew and pass a templates location so it see the templates in the location specified based on the combo box selection?

    Here is the vba code for the wddialog

    Sub OnChange(control As IRibbonControl, _
    strText As String)
    Select Case control.ID
    Case "cboComboBox"
    ChangeFileOpenDirectory "\\servername\share\cityfolder\templateType"
    End Select

    End Sub

    The xml code

             <group id="customGroup" label="Toronto" >
                <button id="btnButton" label="Toronto Templates" imageMso="TableDesign" onAction="OnAction"/>
                <layoutContainer id="layout1" layoutChildren="vertical">
                  <comboBox id="cboComboBox" label="Template Type" onChange="OnChange">
                    <item id="item1" label="01-Proposal"/>
                    <item id="item2" label="02-Project Admin"/>
                    <item id="item3" label="03-Permit Docs"/>
                    <item id="item4" label="04-Construction Admin"/>
                    <item id="item5" label="05-Inter-Office"/>
                    <item id="item6" label="06-Prime Consultant"/>
                    <item id="item7" label="07-CheckLists"/>
                    <item id="item8" label="08-FootPrint"/>
                    <item id="item9" label="09-Test-Dont Use"/>

    • Edited by WGP47 Thursday, March 1, 2012 2:11 PM
    Thursday, March 1, 2012 1:00 PM


  • Instead of the wdDialogFileOpen I would try to use the msoFileDialogFilePicker.  With it you have control over the path by setting it in the "InitialFileName" property

    Here is an example from one of my apps.

                With wApp.FileDialog(Office.MsoFileDialogType.msoFileDialogFilePicker)
                    .Title = "zAPPs-insert needs the file you want to bring in"
                    .InitialFileName = fName
                    .AllowMultiSelect = True
                    If .Show = 0 Then
                        Exit Sub
                    End If
                    For i = 0 To .SelectedItems.Count - 1
                        rng = wApp.Selection.Range
                        rng.MoveStart(Unit:=Word.WdUnits.wdParagraph, Count:=1)
                        rng.InsertFile(FileName:= _
                            .SelectedItems(i), Range:="", ConfirmConversions:=False, Link:=False, Attachment:=False)
                End With

    Kind Regards, Rich ...

    • Marked as answer by Bruce Song Tuesday, March 20, 2012 9:31 AM
    Thursday, March 1, 2012 2:49 PM