RJSIGKITS
Board Regular
- Joined
- Apr 15, 2013
- Messages
- 109
Hi Guys.
I am trying to make a button that saves the current sheet as a PDF within a directory that is created by clicking a button previously.
So, on my sheet, I have 2 buttons, the 1st creates a filepath with a name according to a reference on the sheet, and saves the excel document.
I now need a second button which saves a PDF of the current sheet into that new directory, but no matter what I try, I keep getting errors...
This is what I have, but the 'SavePDF_Click()' Sub is returning an error runtime 1004 -
I am trying to make a button that saves the current sheet as a PDF within a directory that is created by clicking a button previously.
So, on my sheet, I have 2 buttons, the 1st creates a filepath with a name according to a reference on the sheet, and saves the excel document.
I now need a second button which saves a PDF of the current sheet into that new directory, but no matter what I try, I keep getting errors...
This is what I have, but the 'SavePDF_Click()' Sub is returning an error runtime 1004 -
Code:
Private Sub Save1_Click()Dim Path As String
Dim FileName1 As String
Path = "C:\Users\Richard\Box Sync\Default Sync Folder\4. Richard Johns Design\Web Design\Clients\Complete Flooring"
FileName1 = Range("H5")
If Dir(Path & "\" & FileName1, vbDirectory) = "" Then
MkDir (Path & "\" & FileName1)
MkDir (Path & "\" & FileName1 & "\Quotes")
MkDir (Path & "\" & FileName1 & "\Photos")
MkDir (Path & "\" & FileName1 & "\Photos" & "\Before")
MkDir (Path & "\" & FileName1 & "\Photos" & "\Progress")
MkDir (Path & "\" & FileName1 & "\Photos" & "\After")
MkDir (Path & "\" & FileName1 & "\Invoices")
MkDir (Path & "\" & FileName1 & "\Invoices" & "\Paid")
MsgBox "Success!" & vbCr & "A New Client Record has been created and saved successfully", vbExclamation + vbOKOnly, "Success!"
ThisWorkbook.Sheets("Sales Order").Activate
Else
If MsgBox("A Record Already Exists for this Client" & vbCr & "Click 'OK' to save changes to this record", vbExclamation + vbOKOnly, "Error") = vbOK Then
ThisWorkbook.Save
ThisWorkbook.Sheets("Sales Order").Activate
Exit Sub
End If
End If
ActiveWorkbook.SaveAs Filename:=Path & "\" & FileName1 & "\" & FileName1 & ".xlsm", FileFormat:=52
End Sub
Private Sub SavePDF_Click()
ThisWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Path & "\" & FileName1 & "\" & FileName1 & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub