Sometimes my macro saves correctly, and other times, they save to a different file. Any idea why these are sending documents to the incorrect folder sometimes and the correct one other times? I'm just trying to save the workbook in the same folder that it is already in and add the date at the end - one in PDF format and the other in excel format.
Thank y ou!
Code
Sub SaveAsPDF()
'THIS ONE WORKS
' SaveAsPDF Macro
WBPath = ActiveWorkbook.path
WBName = Replace(ActiveWorkbook.Name, ".xlsm", "")
CustomerName = ActiveSheet.Range("C1").Text
PricingAnalysis = ActiveSheet.Range("C2").Text
currentDate = Format(Date, "MM.DD.YYYY")
ThisWorkbook.Sheets(Array("E_Cover Page", "E_Pricing Analysis (FP)")).Select
newFullPath = WBPath & "\" & WBName & " " & currentDate & ".PDF"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, fileName:=CustomerName & "_" & PricingAnalysis & "_" & currentDate & ".PDF"
'FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
Sub SaveAsFile()
'THIS ONE WORKS
' SaveAsFile Macro
WBPath = ActiveWorkbook.path
WBName = Replace(ActiveWorkbook.Name, ".xlsm", "")
CustomerName = ActiveSheet.Range("B3").Text
PricingAnalysis = ActiveSheet.Range("A1").Text
currentDate = Format(Date, "MM.DD.YYYY")
newFullPath = WBPath & "\" & WBName & " " & currentDate & ".xlsm"
ActiveWorkbook.SaveAs fileName:=CustomerName & "_" & PricingAnalysis & "_" & currentDate & ".xlsm"
'FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
Display More