Jmoz092
Board Regular
- Joined
- Sep 8, 2017
- Messages
- 184
- Office Version
- 365
- 2011
- Platform
- Windows
- MacOS
I saw another thread here about saving excel spreadsheets as PDFs and tried to modify the code (with my woefully lacking VBA skills) into an existing code I received help with here before and I'm having trouble getting the macro to do anything.
I previously received help to get my excel worksheet to SaveAs, that's working, intermittently, sans the occasional "Visual Basic Editor 400" error. I'd like to now apply the same process, to the same worksheet (after users have created input in one or two specific cells) but save it as a PDF to our network.
Below is my attempt to modify the code form this thread, to fit the SaveAs code I was using:
When we run the macro, we're brought to the debug window with an error message box that reads: "Compile error: Named argument not found"
Then the name of the sub is highlighted yellow and "FileFormat:=" is highlighted blue.
Hopefully I'm just making a movie mistake. Thanks for any feedback you're able to provide.
I previously received help to get my excel worksheet to SaveAs, that's working, intermittently, sans the occasional "Visual Basic Editor 400" error. I'd like to now apply the same process, to the same worksheet (after users have created input in one or two specific cells) but save it as a PDF to our network.
Below is my attempt to modify the code form this thread, to fit the SaveAs code I was using:
Code:
Sub PDFtest()
Dim thisfile As String
Dim FilePth As String
If Application.PathSeparator = ":" Then
FilePth = "data:officeforms:ultrasoundorders:" & Range("Ak1").Value & ":" & Range("Ak2").Value & ":"
thisfile = Range("Ak3").Value
ActiveWorkbook.ExportAsFixedFormat FilePth & thisfile, FileFormat:=xlTypePDF, Filename:=thisfile, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
Else
FilePth = "data\officeforms\ultrasoundorders\" & Range("Ak1").Value & "\" & Range("Ak2").Value & "\"
thisfile = Range("Ak3").Value
ActiveWorkbook.ExportAsFixedFormat FilePth & thisfile, FileFormat:=xlTypePDF, Filename:=thisfile, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
End If
End Sub
When we run the macro, we're brought to the debug window with an error message box that reads: "Compile error: Named argument not found"
Then the name of the sub is highlighted yellow and "FileFormat:=" is highlighted blue.
Hopefully I'm just making a movie mistake. Thanks for any feedback you're able to provide.