Commands-Only Microsoft Word Add In

22 Views Asked by At

I want to make a Microsoft Word add in that only introduces XML commands in the manifest; that is, it does not need a task pane. Is this possible? Are there any examples of what that might look like, or alternative means of doing this? I cannot see any examples here: https://learn.microsoft.com/en-us/office/dev/add-ins/develop/create-addin-commands.

2

There are 2 best solutions below

0
Zia ul Qamar On

Yes possible you can create only command add-in for Word using Office js

please read this documentation and implement it if you need any help so I can help you

https://learn.microsoft.com/en-us/office/dev/add-ins/develop/yeoman-generator-overview

you can try this XML

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<OfficeApp
xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">
<Id>b2a5eb0d-0f48-4332-89c9-270bb93945fb</Id>
<Version>1.0.0.0</Version>
<ProviderName>Contoso</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Command Addin"/>
<Description DefaultValue="A template to get started."/>
<IconUrl DefaultValue="https://localhost:3000/assets/icon-32.png"/>
<HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-64.png"/>
<SupportUrl DefaultValue="https://www.contoso.com/help"/>
<AppDomains>
    <AppDomain>https://www.contoso.com</AppDomain>
</AppDomains>
<Hosts>
    <Host Name="Document"/>
</Hosts>
<DefaultSettings>
    <SourceLocation DefaultValue="https://localhost:3000/taskpane.html"/>
</DefaultSettings>
<Permissions>ReadWriteDocument</Permissions>
<VersionOverrides
    xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Hosts>
        <Host xsi:type="Document">
            <DesktopFormFactor>
                <GetStarted>
                    <Title resid="GetStarted.Title"/>
                    <Description resid="GetStarted.Description"/>
                    <LearnMoreUrl resid="GetStarted.LearnMoreUrl"/>
                </GetStarted>
                <FunctionFile resid="Commands.Url"/>
                <ExtensionPoint xsi:type="PrimaryCommandSurface">
                    <CustomTab id="TabHome">
                        <Group id="Contoso.Group1">
                            <Label resid="Contoso.Group1Label" />
                            <!-- Icons. Required sizes 16,32,80, optional 20, 24, 40, 48, 64. Strongly recommended to provide all sizes for great UX. -->
                            <!-- Use PNG icons. All URLs on the resources section must use HTTPS. -->
                            <Icon>
                                <bt:Image size="16" resid="Contoso.tpicon_16x16" />
                                <bt:Image size="32" resid="Contoso.tpicon_32x32" />
                                <bt:Image size="80" resid="Contoso.tpicon_80x80" />
                            </Icon>
                            <Control xsi:type="Button" id="Contoso.TaskpaneButtonSave">
                                <Label resid="Contoso.TaskpaneButton.Save" />
                                <Supertip>
                                    <!-- ToolTip title. resid must point to a ShortString resource. -->
                                    <Title resid="Contoso.TaskpaneButton.Save" />
                                    <!-- ToolTip description. resid must point to a LongString resource. -->
                                    <Description resid="TaskpaneButton.Tooltip" />
                                </Supertip>
                                <Icon>
                                    <bt:Image size="16" resid="Save16" />
                                    <bt:Image size="32" resid="Save32" />
                                    <bt:Image size="80" resid="Save80" />
                                </Icon>
                                <!-- This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFunction or ShowTaskpane. -->
                                <Action xsi:type="ExecuteFunction">
                                    <FunctionName>Save</FunctionName>
                                </Action>
                            </Control>
                        </Group>
                        <Label resid="customTabLabel1" />
                    </CustomTab >
                </ExtensionPoint>
            </DesktopFormFactor>
        </Host>
    </Hosts>
    <Resources>
        <bt:Images>
            <bt:Image id="Contoso.tpicon_16x16" DefaultValue="https://localhost:3000/assets/Person16x16.png" />
            <bt:Image id="Contoso.tpicon_32x32" DefaultValue="https://localhost:3000/assets/Person32x32.png" />
            <bt:Image id="Contoso.tpicon_80x80" DefaultValue="https://localhost:3000/assets/Person80x80.png" />
            <bt:Image id="Save16" DefaultValue="https://localhost:3000/assets/SaveRule16.png" />
            <bt:Image id="Save32" DefaultValue="https://localhost:3000/assets/SaveRule32.png" />
            <bt:Image id="Save80" DefaultValue="https://localhost:3000/assets/SaveRule80.png" />
        </bt:Images>
        <bt:Urls>
            <bt:Url id="GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812"/>
            <bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html"/>
            <bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html"/>
        </bt:Urls>
        <bt:ShortStrings>
            <bt:String id="GetStarted.Title" DefaultValue="Get started with your sample add-in!"/>
            <bt:String id="CommandsGroup.Label" DefaultValue="info"/>
            <bt:String id="CommandsGroup.Label2" DefaultValue="_"/>
            <bt:String id="CommandsGroup.Labe3" DefaultValue="_"/>
            <bt:String id="TaskpaneButton.Label" DefaultValue="Connections"/>
            <bt:String id="customTabLabel1" DefaultValue="Command Addin"/>
            <bt:String id="Contoso.Group1Label" DefaultValue="Rulesets" />
            <bt:String id="Contoso.TaskpaneButton.Save" DefaultValue="Save" />
        </bt:ShortStrings>
        <bt:LongStrings>
            <bt:String id="GetStarted.Description" DefaultValue="Your sample add-in loaded succesfully. Go to the HOME tab and click the 'Show Taskpane' button to get started."/>
            <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Click to Show a Taskpane"/>
        </bt:LongStrings>
    </Resources>
</VersionOverrides>
0
Rick Kirkham On

Yes. You can do this. Here is an example manifest for a Word add-in that only has a function command; no taskpane.

<?xml version="1.0" encoding="UTF-8"?>
<!-- To learn about the Office Add-ins XML manifest, see https://go.microsoft.com/fwlink/?linkid=2252563 -->
<OfficeApp 
      xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" 
      xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides"
      xsi:type="TaskPaneApp">

<Id>8978b286-b4e3-4167-b256-8347a6794793</Id>
<Version>1.0.0.0</Version>
<ProviderName>[Provider name]</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="WordWebAddIn-UpdateTemplate" />
<Description DefaultValue="WordWebAddIn-UpdateTemplate"/>
<IconUrl DefaultValue="https://localhost:3000/Images/Button32x32.png" />
<SupportUrl DefaultValue="http://www.contoso.com" />
<AppDomains>
  <AppDomain>AppDomain1</AppDomain>
  <AppDomain>AppDomain2</AppDomain>
  <AppDomain>AppDomain3</AppDomain>
</AppDomains>

<Hosts>
  <Host Name="Document" />
</Hosts>
<DefaultSettings>
  <SourceLocation DefaultValue="https://localhost:3000/Home.html" />
</DefaultSettings>

<Permissions>ReadWriteDocument</Permissions>

<VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
<Hosts>
  <Host xsi:type="Document">
    <DesktopFormFactor>
      <GetStarted>
        <Title resid="Contoso.GetStarted.Title"/>
        <Description resid="Contoso.GetStarted.Description"/>
        <LearnMoreUrl resid="Contoso.GetStarted.LearnMoreUrl"/>
      </GetStarted>
      <FunctionFile resid="Contoso.DesktopFunctionFile.Url" />

      <ExtensionPoint xsi:type="PrimaryCommandSurface">
        <OfficeTab id="TabHome">
          <Group id="Contoso.Group1">
            <Label resid="Contoso.Group1Label" />
            <Icon>
              <bt:Image size="16" resid="Contoso.tpicon_16x16" />
              <bt:Image size="32" resid="Contoso.tpicon_32x32" />
              <bt:Image size="80" resid="Contoso.tpicon_80x80" />
            </Icon>
            <Control xsi:type="Button" id="Contoso.FunctionCommandButton">
              <Label resid="Contoso.FunctionCommand.Label" />
              <Supertip>
                <Title resid="Contoso.FunctionCommand.Label" />
                <Description resid="Contoso.FunctionCommand.Tooltip" />
              </Supertip>
              <Icon>
                <bt:Image size="16" resid="Contoso.tpicon_16x16" />
                <bt:Image size="32" resid="Contoso.tpicon_32x32" />
                <bt:Image size="80" resid="Contoso.tpicon_80x80" />
              </Icon>
              <Action xsi:type="ExecuteFunction">
                <FunctionName>insertParagraph</FunctionName>
              </Action>
            </Control>
          </Group>
        </OfficeTab>
      </ExtensionPoint>
    </DesktopFormFactor>
  </Host>
</Hosts>

    <Resources>
      <bt:Images>
        <bt:Image id="Contoso.tpicon_16x16" DefaultValue="https://localhost:3000/Images/Button16x16.png" />
        <bt:Image id="Contoso.tpicon_32x32" DefaultValue="https://localhost:3000/Images/Button32x32.png" />
        <bt:Image id="Contoso.tpicon_80x80" DefaultValue="https://localhost:3000/Images/Button80x80.png" />
      </bt:Images>
      <bt:Urls>
        <bt:Url id="Contoso.DesktopFunctionFile.Url" DefaultValue="https://localhost:3000/Functions/FunctionFile.html" />
        <bt:Url id="Contoso.GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812" />
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="Contoso.FunctionCommand.Label" DefaultValue="Insert Paragraph" />
        <bt:String id="Contoso.Group1Label" DefaultValue="Commands Group" />
        <bt:String id="Contoso.GetStarted.Title" DefaultValue="Get started with your sample add-in!" />
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="Contoso.FunctionCommand.Tooltip" DefaultValue="Click to run a function command." />
        <bt:String id="Contoso.GetStarted.Description" DefaultValue="Your sample add-in loaded successfully. Go to the HOME tab and click the 'Show Task Pane' button to get started." />
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</OfficeApp>