none
Error saving a .docm file in Word 2010 RRS feed

  • Question

  • I currently have a Word Doc (.docm file) in which I have  it set up to fill multiple fields at one time using the Insert tab, Quick Parts, etc.  When I update one field, it updates each other field that I specify.  This works just fine.

    Now, I have a macro set up in which it will print and save my document at one time.  This macro works fine in a .doc or .docx file.  However, when I attempt to add this same print/save macro to the .docm file mentioned above, I get an error message when saving.  A message box pops up with the file directory folder and I usually have to hit "ok" two or three times to get it to save. Then, on occasion, when I reopen the file using Word, it will show up as "read only" and a "ghost copy" of the doc will still be opened (usually preceded with "~")  It seems like Word is still attempting to save the document at this point.  However, I can usually reopen the same doc immediately using Windows Explorer and it will open just fine (NOT as read only).

    Unfortunately, I don't have the error message that I am receiving at this moment.  I can provide it to you tomorrow when I get to work.

    Any ideas why I can't get the Print/Save macro to work in the .docm file with the Insert/Quick Part and have it save without error?  Does this have something to do with Sharepoint?

    I tried to be as specific as possible.  Please let me know if you have any additional questions

    Thank you!

    Patrick


    Patrick
    Tuesday, December 14, 2010 8:13 AM

Answers

  • If you save it as a dotm template and then use File>New to create a new document from that template, the document that is created will, be saved in the default format set under File>Options>Save

    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "Patrick1977" wrote in message news:fada758d-3e83-487d-b6b4-f67de7621a13@communitybridge.codeplex.com...

    One last question, Doug.  If I save it is as a template, can I then go in to save options and select to save it is a .docx file for all future saves or would I need to manually save it is a .docx file?

    -- Patrick


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    • Marked as answer by Bessie Zhao Tuesday, December 21, 2010 9:35 AM
    Wednesday, December 15, 2010 11:34 PM

All replies

  • This is somewhat confusing as DOCX which you say works doesn't support macros.
    It might help if you post your problematic code.



    <Patrick1977> wrote in message news:276a6da3-5004-488d-8bd1-e95982f6afde@communitybridge.codeplex.com...

    I currently have a Word Doc (.docm file) in which I have  it set up to fill multiple fields at one time using the Insert tab, Quick Parts, etc.  When I update one field, it updates each other field that I specify.  This works just fine.

    Now, I have a macro set up in which it will print and save my document at one time.  This macro works fine in a .doc or .docx file.  However, when I attempt to add this same print/save macro to the .docm file mentioned above, I get an error message when saving.  A message box pops up with the file directory folder and I usually have to hit "ok" two or three times to get it to save. Then, on occasion, when I reopen the file using Word, it will show up as "read only" and a "ghost copy" of the doc will still be opened (usually preceded with "~")  It seems like Word is still attempting to save the document at this point.  However, I can usually reopen the same doc immediately using Windows Explorer and it will open just fine (NOT as read only).

    Unfortunately, I don't have the error message that I am receiving at this moment.  I can provide it to you tomorrow when I get to work.

    Any ideas why I can't get the Print/Save macro to work in the .docm file with the Insert/Quick Part and have it save without error?  Does this have something to do with Sharepoint?

    I tried to be as specific as possible.  Please let me know if you have any additional questions

    Thank you!

    Patrick


    --------------------------------------------------------------------------------
    Patrick


    Graham Mayor - Word MVP
    www.gmayor.com
    Posted via the Communities Bridge
    http://communitybridge.codeplex.com/
    Tuesday, December 14, 2010 8:58 AM
  • I agree this is confusing, Graham.  A .doc or .docx file will allow me to have this print/save macro.  However, if I attempt to put any addtional macros or content controls in addtion to the macro, it will then require me to save it as a .docm file.

    The error message I am receiving when attempting to print/save using this macro is:

    'G\COL\Customer Care\CMSRCC\General\515.docm' is currently in use.  Try again later.

    Is that the problematic code you are referring to? 

    Then, in the "Open" window in Word (if I attempt to reopen the doc), it shows ~$515.docm as still open even though I closed out of the doc.

    Hope this information helps!  I really appreciate your assistance!

    Patrick


    Patrick
    Tuesday, December 14, 2010 10:17 PM
  • The "problematic code" that Graham asked to see was the code in the macro that you have setup that will print and save the document at one time.

    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "Patrick1977" wrote in message news:37bee1e3-e2ba-4873-bc66-c0db5b079cc7@communitybridge.codeplex.com...

    I agree this is confusing, Graham.  A .doc or .docx file will allow me to have this print/save macro.  However, if I attempt to put any addtional macros or content controls in addtion to the macro, it will then require me to save it as a .docm file.

    The error message I am receiving when attempting to print/save using this macro is:

    'G\COL\Customer Care\CMSRCC\General\515.docm' is currently in use.  Try again later.

    *Is that the problematic code you are referring to? *

    *Then, in the "Open" window in Word (if I attempt to reopen the doc), it shows *~$515.docm as still open even though I closed out of the doc.

    Hope this information helps!  I really appreciate your assistance!

    Patrick

    -- Patrick


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    Wednesday, December 15, 2010 12:48 AM
  • Sorry for the confusion.

    Sub PrintSave()
    '
    ' PrintSave Macro
    ' Print and Save
    '
        Selection.HomeKey Unit:=wdStory
        ChangeFileOpenDirectory _
            "G:\COL\CustomerCare\CMSRCC\General\Team Mason\O'Connor\Approved Letters\"
        ActiveDocument.SaveAs FileName:= _
            "G:\COL\CustomerCare\CMSRCC\General\Team Mason\O'Connor\Approved Letters\515.docm" _
            , FileFormat:=wdFormatXMLDocumentMacroEnabled, LockComments:=False, _
            Password:="", AddToRecentFiles:=True, WritePassword:="", _
            ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
            SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
            False
        Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
            wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
            ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
            False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
            PrintZoomPaperHeight:=0
    End Sub


    Patrick
    Wednesday, December 15, 2010 12:56 AM
  • There is no need to change the file open directory to save a document in a particular folder.  More to the point however, are you sure that the folder into which you are trying to save the document does exist?

    If the file 515.docm exists in that folder, do you want to overwrite it?

    If there is a file with the name ~$515.docm in the folder when Word is not running, then that file will need to be deleted as it is a hangover from some previous failed attempt and its presence will prevent you from saving a document with that name.

    The code can be reduced to:

    With ActiveDocument
        . .SaveAs FileName:= _
             "G:\COL\CustomerCare\CMSRCC\General\Team Mason\O'Connor\Approved Letters\515.docm"
        .PrintOut Background:=False
        .Close wdDoNotSaveChanges
    End With

    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "Patrick1977" wrote in message news:fec922e8-6fa9-470d-940b-1af8b0cffaf8@communitybridge.codeplex.com...

    Sorry for the confusion.

    *Sub PrintSave()
    '
    ' PrintSave Macro
    ' Print and Save
    '
        Selection.HomeKey Unit:=wdStory
        ChangeFileOpenDirectory _
            "G:\COL\CustomerCare\CMSRCC\General\Team Mason\O'Connor\Approved Letters\"
        ActiveDocument.SaveAs FileName:= _
            "G:\COL\CustomerCare\CMSRCC\General\Team Mason\O'Connor\Approved Letters\515.docm" _
            , FileFormat:=wdFormatXMLDocumentMacroEnabled, LockComments:=False, _
            Password:="", AddToRecentFiles:=True, WritePassword:="", _
            ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
            SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
            False
        Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
            wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
            ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
            False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
            PrintZoomPaperHeight:=0
    End Sub
    *

    -- Patrick


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    Wednesday, December 15, 2010 7:35 AM
  • I found that unless I added the file format the resulting file could not be opened

    With ActiveDocument
        .SaveAs FileName:= _
             "G:\COL\CustomerCare\CMSRCC\General\Team Mason\O'Connor\Approved Letters\515.docm", _
        FileFormat:=wdFormatXMLDocumentMacroEnabled
        .PrintOut Background:=False
        .Close wdDoNotSaveChanges
    End With

    However it seems that you are opening an existing document, making changes to it printing and then saving it again using a macro in that document. Sooner or later this will bite you, resulting in document loss. It would be better if you saved the document as a macro enabled template and created new DOCX documents from it.



    <Doug Robbins [MVP]> wrote in message news:5dbdab88-0a88-433d-b32b-29d3ccb274c1@communitybridge.codeplex.com...

    There is no need to change the file open directory to save a document in a particular folder.  More to the point however, are you sure that the folder into which you are trying to save the document does exist?

    If the file 515.docm exists in that folder, do you want to overwrite it?

    If there is a file with the name ~$515.docm in the folder when Word is not running, then that file will need to be deleted as it is a hangover from some previous failed attempt and its presence will prevent you from saving a document with that name.

    The code can be reduced to:

    With ActiveDocument
       . .SaveAs FileName:= _
            "G:\COL\CustomerCare\CMSRCC\General\Team Mason\O'Connor\Approved Letters\515.docm"
       .PrintOut Background:=False
       .Close wdDoNotSaveChanges
    End With

    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "Patrick1977" wrote in message news:fec922e8-6fa9-470d-940b-1af8b0cffaf8@communitybridge.codeplex.com...

     Sorry for the confusion.

     *Sub PrintSave()
     '
     ' PrintSave Macro
     ' Print and Save
     '
         Selection.HomeKey Unit:=wdStory
         ChangeFileOpenDirectory _
             "G:\COL\CustomerCare\CMSRCC\General\Team Mason\O'Connor\Approved Letters\"
         ActiveDocument.SaveAs FileName:= _
             "G:\COL\CustomerCare\CMSRCC\General\Team Mason\O'Connor\Approved Letters\515.docm" _
             , FileFormat:=wdFormatXMLDocumentMacroEnabled, LockComments:=False, _
             Password:="", AddToRecentFiles:=True, WritePassword:="", _
             ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
             SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
             False
         Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
             wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
             ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
             False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
             PrintZoomPaperHeight:=0
     End Sub
     *

     -- Patrick



    --------------------------------------------------------------------------------
    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org


    Graham Mayor - Word MVP
    www.gmayor.com
    Posted via the Communities Bridge
    http://communitybridge.codeplex.com/
    Wednesday, December 15, 2010 10:07 AM
  • Thank you, Doug!  I don't know how to write scripts using VB so I have to depend on writing macros by going through the steps and using shortcut keystrokes.
    Patrick
    Wednesday, December 15, 2010 6:28 PM
  • One last question, Doug.  If I save it is as a template, can I then go in to save options and select to save it is a .docx file for all future saves or would I need to manually save it is a .docx file?
    Patrick
    Wednesday, December 15, 2010 6:50 PM
  • If you save it as a dotm template and then use File>New to create a new document from that template, the document that is created will, be saved in the default format set under File>Options>Save

    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "Patrick1977" wrote in message news:fada758d-3e83-487d-b6b4-f67de7621a13@communitybridge.codeplex.com...

    One last question, Doug.  If I save it is as a template, can I then go in to save options and select to save it is a .docx file for all future saves or would I need to manually save it is a .docx file?

    -- Patrick


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    • Marked as answer by Bessie Zhao Tuesday, December 21, 2010 9:35 AM
    Wednesday, December 15, 2010 11:34 PM