I'm just getting into Office.JS and I'm trying to perform a basic action of clicking a button in the Ribbon UI and doing something on the spreadsheet. All the examples I found related to clicking a cell and using the =CONTOSO...
to perform functions that return variables. Not a single one of my macro's works in this fashion, they either have a UserForm for input, or just "do" something.
I've managed to create a new tab in the ribbon, with a button that should call a function getdata
which really isn't a function, but more a module/sub that I simply want to enter FOO
in cell A1
.
Here are my changes to the default setup that I got running yo office
.
manifest.xml:
<ExtensionPoint xsi:type="PrimaryCommandSurface">
<CustomTab id="TabCustom1">
<!-- <OfficeTab id="TabData"> -->
<Label resid="TabGroup.Label"/>
<Group id="CommandsGroup">
<Label resid="CommandsGroup.Label"/>
<!-- Can only use 1, or default = Far Right
<InsertAfter>TabReview</InsertAfter>
<InsertBefore>TabReview</InsertBefore>
-->
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Control xsi:type="Button" id="TaskpaneButton">
<Label resid="TaskpaneButton.Label"/>
<Supertip>
<Title resid="TaskpaneButton.Label"/>
<Description resid="TaskpaneButton.Tooltip"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Action xsi:type="ShowTaskpane">
<TaskpaneId>ButtonId1</TaskpaneId>
<SourceLocation resid="Taskpane.Url"/>
</Action>
</Control>
<Control xsi:type="Button" id="DoButton">
<Label resid="DoButton.Label"/>
<Supertip>
<Title resid="DoButton.Label"/>
<Description resid="DoButton.Tooltip"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>getData</FunctionName>
</Action>
</Control>
</Group>
<!-- </OfficeTab> -->
</CustomTab>
</ExtensionPoint>
...
<bt:ShortStrings>
<bt:String id="Functions.Namespace" DefaultValue="CONTOSO"/>
<bt:String id="CommandsGroup.Label" DefaultValue="Group Label"/>
<bt:String id="GetStarted.Title" DefaultValue="Get started with your sample add-in!"/>
<bt:String id="TaskpaneButton.Label" DefaultValue="TaskPane Button label"/>
<bt:String id="DoButton.Label" DefaultValue="Do Button label"/>
<bt:String id="TabGroup.Label" DefaultValue="Custom Tab"/>
</bt:ShortStrings>
<bt:LongStrings>
<bt:String id="GetStarted.Description" DefaultValue="Your sample add-in loaded succesfully. Go to the Custom Tab and click the 'Button label' button to get started."/>
<bt:String id="TaskpaneButton.Tooltip" DefaultValue="Click to Show a Taskpane"/>
<bt:String id="DoButton.Tooltip" DefaultValue="Click to Run A Function"/>
</bt:LongStrings>
I'm unsure where to even add this function, I messed around in functions.js
but again, this all seems to be geared towards entering =FUNCNAME
in a cell. Can anyone point me in the right direction?
Thanks