Search code examples
visual-studio-codeoffice-jsnpm-start

disable webview warning when starting (excel) addin


I'm learning how to create addins for office. I'm using vscode and npm's "yo office". While I haven't progressed too far, I've done dozens of compiles and seeing the results in excel while I try/learn new things, and following the online modules for word and excel. Today, for the first time, when all I did was change the text in a header in taskpane.html, when I'm in excel and click on the taskpane button I get

enter image description here

I don't want to see this dialogue, particular when i never had it before.

I've been into launch.json, I tried setting useWebView to false. I've tried commenting out preLaunchTask so that I don't run in debug mode, or adding

"noDebug": true

I've tried disabling the debugger modules in vscode. None of these prevents this dialogue. I've scanned this forum and tried reading the API but they all appear to assume that use of webview debugging is desired. I've spent a bit of time, not as much, seeing if I could "attach VS code to the webview" but this started to go over my head and not something I ever wanted to do in the first place. I'm wondering if there was some update in the last week that added/enabled this "feature".

I appreciate any input on this novice question.

Update#1 I started a new addin project to see what happens. The dialogue appears when doing "npm start", something that did not happen in previous weeks.

Update#2 I did a complete reinstall of npm.js, office.js and vscode. didn't help.

Update#3 I further explored "attach the code" after reading the debugger module further. I added the url line. That did not solve the problem. Not sure what else is missing, particularly since these steps were not previously required.

{
      "name": "Excel Desktop (Edge Chromium)",
      "type": "edge",
      "request": "attach",
      "useWebView": "advanced",
      "port": 9229,
      "timeout": 600000,
      "url": "http://localhost/taskpane.html",
      "webRoot": "${workspaceRoot}",
      "preLaunchTask": "Debug: Excel Desktop",
      "postDebugTask": "Stop Debug"
    }

Solution

  • In npm/vscode, there is a file called package.json that contains scripts on how to run your program. "npm start" is just one of several scripts in package.json, and I presume coders can create their own. I saw that npm start called some module "office-addin-debugging" and i'm not really sure what this is, but a quick google on it exposed a '--no-debug' flag.

    So in package.json:

    "scripts": {
      ...
      "start": "office-addin-debugging start manifest.xml --no-debug",
      ...
    }
    

    Makes the dialogue go away. I'm going to wait a couple of days before closing the question to see if someone is able to provide a most robust answer about how to attach the code to webview, or why the dialogue suddenly appeared when in previous weeks it didn't. i.e. to resolve the dialogue while staying in debug mode.