I have hunted around and am losing my mind trying to figure this out.
So I have the following code:
It works fine when I just stick the string "My Stuff" in for filename, but when I try to use NamingPDF (the created variable) it fails. I need the name that is drawn from the specified ranges.
The one other thing I want is it to open the location where the file is saved to so the user can see...
Thanks for your help
So I have the following code:
Code:
Private Sub CommandButton3_Click() 'exporting to pdf
Dim NamingPDF As String
Dim MyFile As Variant
Dim projectnum As String
Dim Address As String
Dim doneby As String
Dim toDate As String
Sheet3.Select
projectnum = Range("A3").Value
Address = Range("B3").Value
doneby = Range("C3").Value
toDate = Range("E3").Value
If (projectnum = "[#]") Or (Address = "[address]") Or (doneby = "[name]") Or (toDate = "[mmmm dd, yyyy]") Then
MsgBox ("Please fill in required fields first: Project Number, Address, Estimate done by, Date found in Row 3. Thank You")
Else
Sheet3.Select
Sheet1.Select (False)
NamingPDF = "Project Num" & projectnum & ", Cost Estimate" & " - " & toDate & ".pdf"
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="mystuff", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
MsgBox "Your PDF has been successfully exported."
End If
Sheet3.Select
End Sub
It works fine when I just stick the string "My Stuff" in for filename, but when I try to use NamingPDF (the created variable) it fails. I need the name that is drawn from the specified ranges.
The one other thing I want is it to open the location where the file is saved to so the user can see...
Thanks for your help