Hi All,
I have been working on this project for a long time and it is finally nearly done. I have a chunk of code that is intended to grab a range of cells from a form and export that range as a PDF file with a dynamic file name. This was working fine on my computer but when I tried to run the project on my coworker's computer (for whom the project is intended), I got a 1004 Error. The error box says that the PDF may be open, but there were no pdf's open and since the file name is dynamic I don't understand what it's talking about.
Both my coworker and myself are running Office 2016. Their computer does have Adobe Reader installed and I can manually export the range as a PDF just fine but the code does not work. Looking forward to any thoughts. My code is below:
Application.ScreenUpdating = False
Dim AppName As String
Dim WrkOrdr As String
Dim Location As String
Dim AppDate As Date
Dim AppTime As Date
Dim PDFName As String
'Get values from form fields to generate dynamic file name
AppName = ws.Range("H9").value
WrkOrdr = ws.Range("L10").value
Location = ws.Range("H13").value
AppDate = ws.Range("G35").value
AppTime = ws.Range("H35").value
'Generate file name string
PDFName = "ChemApp_" & AppName & "_" & WrkOrdr & "_" & Location & "_" & Format(AppDate + AppTime, "m_d_yyyy_h_mm AM/PM") & ".pdf"
ChDir "H:\PK\Spraying and Fertilizing\Chemical Application Records"
'Error 1004 occurs here with the arrow on the last line
ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"H:\PK\Spraying and Fertilizing\Chemical Application Records\" & PDFName _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
Application.ScreenUpdating = True
Thank you
Bookmarks