Home > Software engineering >  Unable to get the ID of opened .docx file in Docs Add-on
Unable to get the ID of opened .docx file in Docs Add-on

Time:12-03

I am stuck at getting the ID of the .docx file inside Google Docs Add-on. The Id is present in the URL of the browser but I am unable to find any method to get the browser URL.

The method DocumentApp.getActiveDocument().getId() is not helping because it works on Google Docs file, and the file that I open in Google doc is Microsoft Word Format (.docx) file.

I am attaching a screenshot for reference: Reference image

Is there any way to get the ID of .docx file inside Google Docs Add-on? Or is there any way to get the URL of the browser when the .docx is opened in the Google Docs Add-on?

Thanks in advance.

CodePudding user response:

Check out the event object for Workspace Addons using this link. When you build your card, you have access to the event. So you should be able to access it using docs.id within your function.

CodePudding user response:

Answer:

There's no way to retrieve this information for non-Google Docs in Workspace add-ons.

Explanation:

As you mentioned, DocumentApp methods only work for Google Docs files.

Also, the Workspace add-on's Docs event object is only populated if the current document is a Google Docs. I just checked that's the case.

Finally, this information is not retrievable in the context of Workspace add-ons.

Feature request:

You could consider filing a feature request using this Issue Tracker template if you think this functionality could be useful.

  • Related