0
votes

Simple repro steps - Create an Excel app for task pane app for Excel client application Use the below function to print the document name in the task pane Build and add the addin manifest in the trusted Add-in catalog so you can insert it into any Excel document. Launch Excel (a new blank workbook will come up) Click the button to execute the below code You will see blank string in the workbook name Next- save the workbook and then click the button again you will see the correct name displayed in your add-in

function getDataFromSelection() {
        Office.context.document.getSelectedDataAsync(Office.CoercionType.Text,
            function (result) {
                if (result.status === Office.AsyncResultStatus.Succeeded) {

                    Office.context.document.getFilePropertiesAsync(function (asyncResult) {

                        app.showNotification('The document URL is:', '"' + Office.context.document.url + '"');


                    })

                    }

            }
        );

I have an app for Excel

I am trying to read the name of the URL (document name) It works fine in online When the same addin is used in Excel client app it gives correct result for a saved document.

But

When the a new workbook is launched with name eg - Book1.xlsx and we try to print the Office.context.document.url to get the name, we get an empty string.

Is this by design or a bug? is there a way to get the name of the default unsaved document?

1
I have started an internal conversation about this with the team... let us discuss, and we'll get back to you... - Michael Zlatkovsky - Microsoft
Thanks for prompt response Michael ! Will await to hear more on this. - user5501201

1 Answers

1
votes

Upon investigation, it seems like the URL property was indeed designed for Online scenarios, so just a regular file on the computer or an unsaved file will not be returned by this. We have jotted down a backlog item to expose the filename (just the name, not the path) across all platforms, though, so this should be forthcoming in the future.