none
Saving a document in VBA with compatability mode from Word 2010 RRS feed

  • Question

  • I have a very elaborate Word Template written in VBA. And ported throughout the Office line of It works fine in Word 2007 but changes in Word 2010 broke it. If the user clicks "Save As" and then checks the "Maintain Compatibility with previous versions of Word" check box, it works fine. The problem is that I need to save from VBA and when I do so, it saves the document in 2010 format and it breaks my macro.

    The only way to get it to work again is to save it as a "Word 97-2003 Document (*.doc)" and then save it again as a "Word Document (*.dotx)" with the compatibility box checked.

    Any help would be greatly appreciated.

    Thanks!

    Friday, March 18, 2011 7:56 PM

Answers

  • If you use SaveAs2, there is a CompatibilityMode parameter ..
     
        ActiveDocument.SaveAs2 FileName:="whatever", CompatibilityMode:=12
     
     
     

    Enjoy,
    Tony
    www.WordArticles.com
    • Marked as answer by mamerica Friday, April 1, 2011 9:00 PM
    Friday, April 1, 2011 9:44 AM

All replies

  • Hello Mamarica,

    Thanks for posting. For this issue, if I understand you correctly, the VBA code defined in Word 2003 template (.dot) works fine when this word 2003 file is opened in Word 2007. However, when opening it in Word 2010, the VBA code does not work. If we are saving this Word 2003 file with VBA code as Word 2010 format above (dotm), the VBA code works file.

    If yes, would you please do more tests for this issue? As far as I see, you could simplify the VBA in Word 2003 template. By testing it in Word 2010, please see if this issue also happens.

    Also here is a MSDN article about the changes in Word 2010 VBA: http://technet.microsoft.com/en-us/library/cc179199.aspx. Hope this information could help you more or less.

    If you have any concern on this issue, just feel free to follow up. Have a nice day.


    Bessie Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bessie Zhao Friday, March 25, 2011 10:14 AM
    • Unmarked as answer by Bessie Zhao Friday, April 1, 2011 7:22 AM
    Monday, March 21, 2011 6:38 AM
  • Thanks for the reply but it does not help. I read the article that you referenced but it does not help. After re-reading my original post, I can see where it might be confusing. I'll attempt to simplify.

    When a user running Word 2010 opens a document created in 2007, the title bar says "[Compatibility Mode]"

    When they choose "Save As" there is a check box labeled "Maintain Compatibility with previous versions of Word".

    I need to do the same thing with code. In other words, I need to save the document without user interaction.

    Unfortunately, I cannot figure out a way to call the "Save As" function and remain in compatibility mode.

     

    Thanks,

    -Marty

     

     

    Thursday, March 31, 2011 8:03 PM
  • Hi Marty,

    I think this is the command you want.

    ActiveDocument.SaveAs FileName:="MyTestDocument.docx", FileFormat:=wdFormatDocument

    The wdFormatDocument makes it compatible. There is a wdFormatDocumentDefault that will give your the docx formatting.

    Here's a link that describes all of the formatting options.

    http://msdn.microsoft.com/en-us/library/bb238158.aspx

    Hope this helps


    Regards
    Thursday, March 31, 2011 8:48 PM
  • If you use SaveAs2, there is a CompatibilityMode parameter ..
     
        ActiveDocument.SaveAs2 FileName:="whatever", CompatibilityMode:=12
     
     
     

    Enjoy,
    Tony
    www.WordArticles.com
    • Marked as answer by mamerica Friday, April 1, 2011 9:00 PM
    Friday, April 1, 2011 9:44 AM
  • Thank You Tony!

    I apreciate you taking the time. SaveAs2 did the trick! I am forever in your debt!

    Friday, April 1, 2011 9:02 PM