Hello,
I'm trying to create a BeforeSave macro that is triggered when the workbook is saved that exports a pdf copy of the worksheet to a network location. The problem that I am having is that the macro seems to be bypassing the actual save function. I get the desired pdf copy but the actual workbook is not being saved. Therefore, when I closed and reopen the workbook any changes are not saved. Below is the code, thank you for your time
I'm trying to create a BeforeSave macro that is triggered when the workbook is saved that exports a pdf copy of the worksheet to a network location. The problem that I am having is that the macro seems to be bypassing the actual save function. I get the desired pdf copy but the actual workbook is not being saved. Therefore, when I closed and reopen the workbook any changes are not saved. Below is the code, thank you for your time
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
' runs Createlogpdf macro when save ID is selected.
If Not SaveAsUI Then
Worksheets("Log").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:="K:\Common\17 - R&D\MTC work order\Work Order Log" & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
Cancel = True
End If
End Sub