2

I try to debug an Excel Javascript Add-in using Office add-in debugger in Visual Studio Code. I want to configure the debugger to open an existing Excel file.

I use the default configuration "Excel Desktop (Edge Chromium)" in launch.json. But each time I press F5, it creates a new Excel file. The file name is the GUID in the Id tag in manifest.xml, such as a32c06d3-4bbb-4158-8b61-e0349f58019c.xlsx.

I saw this configuration runs a preLaunchTask "Debug: Excel Desktop". This task is specified in task.json:

  "label": "Debug: Excel Desktop",
  "type": "npm",
  "script": "start:desktop -- --app excel,
  "presentation": {
    "clear": true,
    "panel": "dedicated",
  },
  "problemMatcher": []

It is the "npm start:desktop -- --app excel" that creates the new Excel file.

I tried

npm start:desktop -- --app excel 'directory\filename'

But npm still creates the GUID named excel file instead of opening the file specified. I know in Visual Studio, you can launch the debugger and attach to an existing Excel file (explained in this link: Debug Excel add-in written by JavaScript API on an existing workbook). Can Visual Studio Code do the same?

waze
  • 41
  • 3

1 Answers1

2

I looked into the code of office-addin-debugger extension. It does not support debugging an existing office file (excel or word). The way this extension works is that it reads from a template office file in node_modules\office-addin-dev-settings\templates. This template office file (e.g. ExcelWorkbookWithTaskPane.xlsx) includes some manifest xml information. The extension code replaces this information with your add-in xml information, such as Id and version, and then outputs to a new office file (e.g Excel add-in 05a62159-5ecd-42b7-b302-641656dcb776.xlsx). The new office file is then launched and attached to the debugger.

To use an existing excel file, that excel file must have the similar skeleton manifest xml information that be searched and replaced. I haven't found a way to add this info into an excel file.

A workaround is to move the content of your existing excel file into the new file VSC created during debugging. But you can't save that new file. Once saved, the xml information will be lost and that saved file cannot be used in VSC office-addin-debugging.

waze
  • 41
  • 3
  • Bummer, I'm just working on switching from VStudio 2017, but everything just doesn't work as well! I didn't even get this far, but I do often work with existing data currently and this will be another showstopper.... bring back JSDom in VStudio! – FreeSoftwareServers Aug 24 '23 at 03:43