Creating new document and saving causes customdocumentproperties to be cleared RRS feed

  • Question

  • I'll start by saying I'm a novice to VB7 but I've been asked to "fix" an existing issue :-)...


    I have a .docm file that has a several customdocumentproperties on a seperate "properties tab" including one that allows a user to save the current .docm document as a .mht document.

    There is an event handler that runs prior to save that calls the "SaveCopyAs" method

    SaveCopyAs code looks like:


    Sub SaveCopyAs()

    Dim fn As String
    Dim d As New Document

    fn = ThisDocument.FullName
    fn = Left(fn, InStrRev(fn, ".")) & "mht"

    Set d = Application.Documents.Add(ActiveDocument.FullName, , , False)

    'In O12 this is SaveAs, in O14 SaveAs2 but compatible
    d.SaveAs fn, wdFormatWebArchive

    Works just fine in 2007 however when d.Close runs in 2010 the focus changes to the "home" tab and customdocumentproperties on "properties tab" are empty(However closing/reopening the .docm shows the properties still exist and are set)


    Any ideas why?



    Friday, December 9, 2011 4:00 PM

All replies

  • Hi somberg,

    Thanks for posting in the MSDN Forum.

    Would you please clarify the position of the “properties tab”? Does it exist in backstage or ribbon?

    Have a good day,


    Monday, December 12, 2011 8:48 AM
  • Hi somberg

    Word only recognizes the New keyword correctly for the Application object (as in "New Word.Application()"). You shouldn't be using it for anything else. So don't do this:

      Dim d as New Document

    Do this:

      Dim d as Document

    And see if that doesn't make a difference...

    Since this is a VBA question, I'm moving it to the Word for Developers forum. VSTO is a .NET technology, so the VSTO forum is not a good place to try to get help...

    Cindy Meister, VSTO/Word MVP
    Monday, December 12, 2011 10:21 AM
  • Hi Ice,

      The "properties tab" is part of the ribbon.


    Monday, December 12, 2011 2:50 PM