So I have a macro enabled workbook with multiple tabs. as part of the macro, it converts all the tabs to a pdf as part of a package. There is code to select the parent directory to 'print' the pdf documents to. The problem is that when you first open the template from SharePoint and save it somewhere to use, it works fine. Issue is once you've saved it somewhere and then try to move it to another folder and use it, it errors out with the 1004 error stating:
"Document not saved. The document may be open, or an error may have been encountered when saving."
Odd thing is I'm not trying to save the document at all, just run the print to parent directory macro. Below is the code. It gets to the line that starts with wksSheet.ExportAsFixedFormat line and this is where the error occurs. Can't seem to figure out why it works when first saved, but if the file is moved it errors out. Any ideas?
'Sheet by sheet, export to PDF using standard naming convention 'First sheet fully annotated, the remainder are similar Application.ScreenUpdating = False 'Cover Page 'Select the page to export Sheets("Cover Page").Select 'Set it as the active sheet Set wksSheet = ActiveSheet 'Export the worksheet as a PDF with the specified filename 'ThisWorkbook.Path selects the parent directory '& allows you to concatenate strings of text along with variables 'Naming includes the document number, part number pulled from the sheet, and worksheet name wksSheet.ExportAsFixedFormat Type:=xlTypePDF, fileName:= _ ThisWorkbook.Path & "\0 - " & Sheet1.Range("L7") & " " & wksSheet.Name, Quality:=xlQualityStandard, _ IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _ False