1

I am trying to develop an Excel add-in by using JavaScript API for Excel.

I can already make some samples run, launch debugging under Visual Studio. Every time when i launch debugging, it opens a new workbook of Excel.

However, most of time, I need to debug an add-in on an existing workbook. For instance, here is an add-in sample, which opens a blank workbook and adds blank sheets to it. However, I want it to add blank sheets to an existing (opened) workbook. Does anyone know what I should set to debug it on an existing (opened) workbook? Should I modify some lines of code?

Edit 1: enter image description here

3
  • 1
    Can you try changing the project's Debug settings to "Start external program" and set the full path to Excel. Then in the "Command line arguments" box set the full path to the Excel workbook you want to open. Let me know if this works. Commented May 9, 2016 at 8:43
  • I am using Visual Studio 2015, i really don't see "Start external program", please see my update... Commented May 9, 2016 at 11:08
  • 1
    That's the solutions properties, you need to check the properties of the respective project. Commented May 9, 2016 at 13:57

2 Answers 2

2

From http://dev.office.com/docs/add-ins/get-started/create-and-debug-office-add-ins-in-visual-studio

To use an existing document to debug the add-in

  • In Solution Explorer, choose the add-in project folder.

    Note Choose the add-in project and not the web application project.

  • On the Project menu, choose Add Existing Item.

  • In the Add Existing Item dialog box, locate and select the document that you want to add.

  • Choose the Add button to add the document to your project.

  • In Solution Explorer, open the shortcut menu for the project, and then choose Properties.

  • The property pages for the project appear.

  • In the Start Document list, choose the document that you added to the project, and then choose the OK button to close the property pages.

Here is the resulting configuration that you should see:

Solution Explorer and Properties Pane

After that just press F5 (start debugging), and you should be good to go.

~ Michael Zlatkovsky, developer on Office Extensibility team, MSFT

Sign up to request clarification or add additional context in comments.

4 Comments

"In Solution Explorer, open the shortcut menu for the project, and then choose Properties." ==> sorry, where is "the shortcut menu for the project"?
Shortcut menu must be the documentation version of right-click
Micheal - I had this working on an my first test add-in (and it is still working on my test add-in). I created another one today and I simply cannot get it to work. I have tried all possible combinations. It simply does NOT load the add-in with an existing sheet. This seriously slows down development. Help!
See my response below.
1

For anyone else running into this same issue (i.e. tying to set up an existing worksheet for debugging) without having to jump through 3 hoops to insert the add-in every time, this worked for me:

  • Set the Start Document to "New Excel/Word/etc Document"
  • Hit F5 to start debugging.
  • The resulting new document will be read-only and it will be in the Debug/Release folder.
  • Close the document, don't save it.
  • Copy the document to the folder where your Web Add-In manifest is and renamed it to whatever name you prefer.
  • Uncheck "Read Only" int the file's properties.
  • Set the Start Document as described by Michael in his response above.

If you start debug now, the add-in "should" load automatically. If you start without debugging (Ctrl + F5), you should be able to close the document and open it (or a copy of it) from anywhere in the PC and it should load automatically. You can even make changes to your JS code and reload the taskpanes/dialogs and it should take effect.

What did NOT work:

  • Using a blank start document and saving it after inserting the add-in. Once you save it, it loses its connection to the developer add-in.
  • If you start any document in debug mode and save it, it will NOT work the next time! If you want to make any changes to it, DO NOT start in debug mode.

I am not sure if any of these quirks are by design or if a Windows/Office update messed it up for me. Regardless, this is a very painful experience compared to developing VSTOs.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.