ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,736
- Office Version
- 2007
- Platform
- Windows
Morning,
I wish to save a range from my worksheet in the pdf file type.
The code below works fine with no errors etc but when i view the saved pdf i can see my command buttons which on the worksheet are in columns D & E
When i press the command button i only wish to save what i can see in the range F2:P61 so anything outside that range is not saved.
The code in use is as follows,
I wish to save a range from my worksheet in the pdf file type.
The code below works fine with no errors etc but when i view the saved pdf i can see my command buttons which on the worksheet are in columns D & E
When i press the command button i only wish to save what i can see in the range F2:P61 so anything outside that range is not saved.
The code in use is as follows,
Code:
Private Sub CommandButton1_Click() Dim strFileName As String
strFileName = "C:\Users\Ian\Desktop\REMOTES ETC\DR COPY INVOICES.pdf"
If Dir(strFileName) <> vbNullString Then
MsgBox "INVOICE " & " WAS NOT SAVED AS IT ALLREADY EXISTS", vbCritical + vbOKOnly
Exit Sub
End If
With ActiveSheet
.PageSetup.PrintArea = "$F$2:$P$61"
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
MsgBox "INVOICE " & " WAS SAVED SUCCESSFULLY", vbInformation + vbOKOnly
ActiveWorkbook.Save
End With
End Sub