Word template attachment for above
To test the previously included macro, please use this template.
I had to alter the document for file size considerations. I hope this still works. I had problems trying to zip the files, so I couldn't do that to beat the rules. Sorry... I also had to rename it. You will need to change the name back to ".dot" instead of ".doc"
TIA
Print works! How do I save Word document?
Thanks to Charlize. The Wait fixed that problem.
After I used the routine, the boss asked if I could save the Word document so that it could be emailed later. The net of this is that the "print" statement now needs to be a "save".
Code:
ChangeFileOpenDirectory (docPath)
ActiveDocument.SaveAs FileName:=docName, FileFormat:= wdFormatDocument, LockComments:=False, _
Password:="", AddToRecentFiles:= True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
' wrdApp.ChangeFileOpenDirectory (docPath)
' wrdApp.ActiveDocument.SaveAs FileName:=docName, FileFormat:= _
' wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:= False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
The "ChangeFileOpenDirectory" and "docName" variable were traced with the debugger and have the appropriate variables. I turned on Word visibility and I can switch to Word BEFORE the save attempt and see that everything is properly set up.
The commented-out code was a previous attempt to solve this problem.
Here is the original code (and it works thanks to Charlize and others!) that I wanted to replace:
Code:
wrdApp.Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= wdPrintDocumentContent, Copies:=1, Pages:="", _
PageType:=wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
The error comes immediately in the debugger, so I'm sure that the "object" is checking my request and finding some error.
Any ideas?