Skip to content

Cannot retrieve document properties from PowerPoint #5523

Closed
@ChrisMGeo

Description

@ChrisMGeo

Provide required information needed to triage your issue

I am facing an issue with PowerPoint.DocumentProperties. I have an Add-In meant to work with PowerPoint, Excel and Word. I took the default manifest.xml and added <Host> tags for both <OfficeApp><Hosts></></> (<Host Name="..."/>) and <OfficeApp><VersionOverrides><Hosts></></></> (<Host xsi:type="...">...</Host>).

<?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>......</Id>

  <Version>1.0.0.0</Version>

  <ProviderName>Contoso</ProviderName>

  <DefaultLocale>en-US</DefaultLocale>

  <DisplayName DefaultValue="Add-In Name"/>

  <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"/>

    <Host Name="Workbook"/>

    <Host Name="Presentation"/>

  </Hosts>

  <DefaultSettings>

    <SourceLocation DefaultValue="https://localhost:3000/taskpane.html"/>

  </DefaltSettings>

  <Permissions>ReadWriteocument</Permissions>

  <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappvrsionoverrides" 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">

            <OfficeTab id="TabHome">

              <Group id="CommandsGroup">

                <Label resid="CommandsGroup.Label"/>

                <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>

              </Group>

            </OfficeTab>

          </ExtensionPoint>

        </DesktopFormFactor>

      </Host>

      <Host xsi:type="Workbook">

        <DesktopFormFactor>

          <GetStarted>

            <Title resid="GetStarted.Title"/>

            <Description resid="GetStarted.Description"/>

            <LearnMoreUrl resid="GetStarted.LearnMoreUrl"/>

          </GetStarted>

          <FunctionFile resid="Commands.Url"/>

          <ExtensionPoint xsi:type="PrimaryCommandSurface">

            <OfficeTab id="TabHome">

              <Group id="CommandsGroup">

                <Label resid="CommandsGroup.Label"/>

                <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>

              </Group>

            </OfficeTab>

          </ExtensionPoint>

        </DesktopFormFactor>

      </Host>

      <Host xsi:type="Presentation">

        <DesktopFormFactor>

          <GetStarted>

            <Title resid="GetStarted.Title"/>

            <Description resid="GetStarted.Description"/>

            <LearnMoreUrl resid="GetStarted.LearnMoreUrl"/>

          </GetStarted>

          <FunctionFile resid="Commands.Url"/>

          <ExtensionPoint xsi:type="PrimaryCommandSurface">

            <OfficeTab id="TabHome">

              <Group id="CommandsGroup">

                <Label resid="CommandsGroup.Label"/>

                <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>

              </Group>

            </OfficeTab>

          </ExtensionPoint>

        </DesktopFormFactor>

      </Host>

    </Hosts>

    <Resources>

      <bt:Images>

        <bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>

       <bt:Image id="Icon.32x32" DefaultValu="https://localhost:3000/assets/icon-32.png"/>

       <bt:Image id="Icon.80x80" DefaultValu="https://localhost:3000/assets/icon-80.png"/>

     </bt:Images>

      <bt:Urls>

        <b:Url id="GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812"/

        <bt:Url id="Commands.Url" DefaultValu="https://localhost:3000/commands.html"/>

        bt:Url id="Taskpane.Url" DefaultValu="https://localhost:3000/taskpane.html"/>

      </t:Urls>

      <bt:ShortStrings>

       <bt:String id="GetStarted.Title" DefaultValue="Get started with your sample add-in!"/>

        <bt:String id="CommandsGroup.Label" DefaultValue="Commands Group"/>

        <bt:String id="TaskpaneButton.Label" DefaultValue="Add-In Name"/>

      </bt:ShortStrings>

      <bt:LongStrings>

        <bt:String id="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:String id="TaskpaneButton.Tooltip" DefaultValue="Click to Show a Task Pane"/>

      </bt:LongStrings>

    </Resources>

  </VersionOverrides>

</OfficeApp>

I have a function I mean to use in both which extracts the document properties of each app:

export async function getProperties(propertyNames?: string | string[]): Promise<object> {

  let res = {};

 

  // Check which host the add-in is running in

  const host = Office.context.host;

 

  if (host === Office.HostType.Word) {

    await Word.run(async (context) => {

      const builtInProperties: Word.DocumentProperties = context.document.properties;

      builtInProperties.load(propertyNames);

      await context.sync();

      res = JSON.parse(JSON.stringify(builtInProperties));

    });

  } else if (host === Office.HostType.Excel) {

    await Excel.run(async (context) => {

      const workbookProperties = context.workbook.properties;

      workbookProperties.load(propertyNames);

      await context.sync();

      res = JSON.parse(JSON.stringify(workbookProperties));

    });

  } else if (host === Office.HostType.PowerPoint) {

    await PowerPoint.run(async (context) => {

      const presentationProperties = context.presentation.properties;

      presentationProperties.load(propertyNames);

      await context.sync();

      res = JSON.parse(JSON.stringify(presentationProperties));

    });

  } else {

    throw new Error("Unsupported host application.");

  }

  console.log(res)

 

  return res;

}

Currently this function works for Excel and Word, but for PowerPoint returns nothing. I've tried specific propertyNames like keywords and *, but everytime the object is empty.

Your Environment

  • Platform [PC desktop, Mac, iOS, Office on the web]: PC Laptop
  • Host [Excel, Word, PowerPoint, etc.]: PowerPoint
  • Office version number: ______
  • Operating System: Windows 10
  • Browser (if using Office on the web): N/A

Steps to reproduce

  1. Create a new Office Add-In using Yeoman with React template.
  2. Copy over the above code.

Metadata

Metadata

Assignees

Labels

Area: ExcelIssue related to Excel add-insArea: WordIssue related to Word add-ins

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions