Author Topic: Changing Default Value of EditBox  (Read 1344 times)

0 Members and 1 Guest are viewing this topic.

adang

  • Newbie
  • *
  • Posts: 3
Changing Default Value of EditBox
« on: July 15, 2021, 12:15:19 PM »
I have a customUI with an EditBox and want to set the default value when the User opens the Visio template file.
Here is the customUI xml:
Code
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="CustomRibbonOnLoad">
  <ribbon>
    <tabs>
      <tab id="CustomTab1" label="My Tab">
        <group
                        id="BOMGroup"
                        label="BOM"
                        autoScale="true"
                        >
                            <editBox id="BOMLink" label="BOM Link:" onChange="ThisDocument.BOMLink_onChange" getText = "ThisDocument.BOM_getText"/>
                 
                    <button
                            id="GoToBOMLink"
                            label="Go To BOM Link"
                            screentip="Opens Browser to go to BOM Link"
                            size="large"
                            imageMso="HyperlinkOpenExcel"     
                            onAction="ThisDocument.OpenBOM"
                            />
                </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

So I expect BOMLink to have its default text updated through its getText callback function.

Here is my vba code:

Code
Dim MyRibbon As IRibbonUI

Sub CustomRibbonOnLoad(ribbon As IRibbonUI)
 Set MyRibbon = ribbon
 Debug.Print "CustomRibbonOnLoad called"
 MyRibbon.InvalidateControl ("BOMLink") ' Invalidates the cache of a single control
End Sub

Sub myFunction()
 MyRibbon.InvalidateControl ("BOMLink") ' Invalidates the cache of a single control
End Sub


'Callback for BOMLink onChange
Sub BOMLink_onChange(control As IRibbonControl, text As String)
End Sub

'Callback for BOMLink getText
Sub BOM_getText(control As IRibbonControl, ByRef returnedVal)
    Debug.Print "Callback UpdateBOMLinkText"
    MyRibbon.InvalidateControl ("BOMLink") ' Invalidates the cache of a single control
    returnedVal = "test default text"
End Sub

'Callback for GoToBOMLink onAction
Sub OpenBOM(control As IRibbonControl)
    Debug.Print "Callback OpenBOM"
End Sub


As it stands right now, I do not get the "CustomRibbonOnLoad called" debug print, but I do get the "Callback UpdateBOMLinkText" called. However the text does not change to the default test text as expected.
When I open the document and click the Custom Tab I get this in the debug:

>invokeVBA: ThisDocument.BOM_getText
Callback UpdateBOMLinkText
<invokeVBA: 0x80020009

I am attempting to fill it with "test default text" for now, but in the future want to call upon the Shapesheet and pull data from there to fill by default.

Any help would be appreciated, thanks!
« Last Edit: July 15, 2021, 12:36:46 PM by adang »