none
Excel says "Document Not Saved". How to solve?

    Question

  • Good day, all.

    I've found the following issue (step by step):

    1. Create a new Excel Template based on VSTO in Visual Studio
    2. Remove two of three sheets from the template's workbook that VS has just generated, so your template will consist of the only one page.
    3. Save the template and project.
    4. Run VSTO template 
    5. Try to add a new sheet using template created in (2).
    6. Now, drag Sheet1 and drop it before Sheet2 (which was just added)
    7. Try to save document.
    8. Get a "Document not saved" message

    Excel just says "Document not saved" without any explanation and events. But! If you saved a document before (6), i.e. before sheets swapping, then Excel will save a document without any troubles. Moreover, if your template will consist of more then one page, the error will not occur. Does anyone has a clue about described behavior?

    The another question from this area:

    If I'll add a new sheet, after it remove "primary" sheet (Sheet1, this is the only one sheet in template), and then save my document, so Excel will not load document correctly: it will ignore VSTO with an error.

    Thaks in forward,

    /Dmitriy

    Friday, March 16, 2007 2:50 PM

Answers

  • Hi Dmitriy

     

    <<If I'll add a new sheet, after it remove "primary" sheet (Sheet1, this is the only one sheet in template), and then save my document, so Excel will not load document correctly: it will ignore VSTO with an error.>>

     

    I think I can at least provide you with an answer for this part of your question (and at the same time "bump" this message to give it visibility again). When you create a VSTO project for Excel, it generates internal objects for the workbook and for each individual sheet. If a sheet is removed from the workbook, then the project can't properly resolve the next time it's opened because the code is looking for an object that no longer exists. Note that it doesn't matter what the sheet is named, or which position it holds in the workbook. When VSTO creates the VSTO project it adds invisible ActiveX controls to each sheet to identify it (something that doesn't happen when you insert a sheet at runtime).

     

    I suspect that your first (main) question may be a bug...

    Tuesday, April 03, 2007 1:29 PM
    Moderator

All replies

  • Dimitry,

    Interesting, can You tell us more about the configuration and any Service Pack etc in use. 

    Friday, March 16, 2007 7:17 PM
  • Dennis Wallentin,

    OS - Windows XP, .NET Framework 2.0, Office 2003 + SP1, VSTO 2005 + VSTO 2005SE, Visual Studion 2005.

    Actually not only I have this problem. Try to reproduce the bug, it should appear, I suppose. The only condition - is to provide only one sheet in template (with VSTO support) and then add this template in an unsaved document, which was created using the template. Then swap pages.

    Thanks,

    Dmitriy

    Monday, March 19, 2007 6:58 AM
  • Dmitriy,

    I use the following config and can't reproduce the error:

    Windows XP SP2
    .NET Framework 2.0
    Office 2003 + SP2
    VSTO 2005
    VSTO 2005 SE
    Visual Studio Pro 2005 SP1

    It would be interesting to see if any other can reproduce the error. Meanwhile I recommend that You update Office and Visual Studio with the latest SPs.

    Monday, March 19, 2007 11:49 AM
  • For now I have the same config. But the problem is still present.

    Probably you understood me not correctly.

    Let's suppose that we've created a new VSTO Template "IssueTemplate". VS will add 3 sheets and we should remove "Sheet2" and "Sheet3". After it, save all changes (both in VS project and in Excel built-in designer) and build the project. Copy "IssueTemplate.xlt" into your Office Templates folder (for example, "C:\Documents and Settings\<Your Profile Name>\Application Data\Microsoft\Templates\"). This path can be found in Word (I really wonder, why only Word can set up this values for all Office?): Tools->Options->FileLocations tab, UserTemplates parameter in a list below). In any way, when you click on "Insert New Sheet", you should see "IssueTemplate.xlt" in the offered list. After all these actions, run your template from VS. You should pick exactly "IssueTemplate.xlt" as a new sheet, when VS stated Excel! And then try to swap sheets.

    If you'll give me some kind of contacts (MSN, ICQ, e-mail), I'll can explain details much slightly or just give you source code. By the way, does this forum allows to attach files?

    Thanks,

    /Dmitriy

    Monday, March 19, 2007 3:16 PM
  • Dennis Wallentin,

    Your silence means that you reproduced the error? Have you any ideas then?

    /Dmitriy.

    Monday, March 26, 2007 4:54 AM
  • Hi Dmitriy

     

    <<If I'll add a new sheet, after it remove "primary" sheet (Sheet1, this is the only one sheet in template), and then save my document, so Excel will not load document correctly: it will ignore VSTO with an error.>>

     

    I think I can at least provide you with an answer for this part of your question (and at the same time "bump" this message to give it visibility again). When you create a VSTO project for Excel, it generates internal objects for the workbook and for each individual sheet. If a sheet is removed from the workbook, then the project can't properly resolve the next time it's opened because the code is looking for an object that no longer exists. Note that it doesn't matter what the sheet is named, or which position it holds in the workbook. When VSTO creates the VSTO project it adds invisible ActiveX controls to each sheet to identify it (something that doesn't happen when you insert a sheet at runtime).

     

    I suspect that your first (main) question may be a bug...

    Tuesday, April 03, 2007 1:29 PM
    Moderator
  • Dmitriy

     

    Yes I can reproduce it.
      The alert system here has been out of function so there was a delay on all the threads I subscribe to.

      However, that should not mean that You can sidestep the Netiquette protocol which per se means to be polite. Being unpolite means
      only that the issues You may have are totally disregarded as, after all, it's not us who try to help other that have the issues. 

    Tuesday, April 03, 2007 5:01 PM
  • Virge, does Cindy's post resolve your issue?
    Friday, April 06, 2007 9:45 PM
  • Good day again.

    I didn't reply for a long time due to the forum issues - it was impossible to write an answer (page not loaded) Sad

     

    First of all, I'd like to say to Dennis "Sorry". I really didn't want to offend you, sorry for my bad English. You (and meSmile ) already know that this forum sometimes fails.

     

    Cindy Meister, thank you for the reply, it looks like you're right, but the problem is still unsolved. Probably, the root of the evil in document's manifest? Have you any ideas how to update manifests through VSTO in run-time? I mean in currently opened document. I also suspect that this problem can occur because of "ready" document (i.e. with two sheets) has more then one code backbone or because of different XL template location.

    But the most likely reason - is the Microsoft bug.

     

    Christa Carpentiere, as you can see, Cindy's post did not resolve my issueSad

    Thanks,

    /Dmitriy

    Thursday, May 10, 2007 10:44 AM
  • Hi.

     

    Thanks to all for the ideas and replys, I've solved my (actually, Microsoft's) problem.

     

    /Dmitriy

    Friday, May 18, 2007 7:24 PM
  • Dmitriy

    What do you do to solve it in the end? I have this problem at my work where all computers are running identical (or near identical) windows XP pro and office 2002 setups. Only a few machines experience this problem (2 out of 30+).

    Cheers,

    Richard
    Thursday, October 11, 2007 3:49 AM