ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Hi,
I have an excel sheet of which i would like to copy a specific range, then save that range as a pdf file on the desktop.
When the file is saved it just needs to be called LR CODES
The range to copy is A1:K16
I have the code below but not entirely sure its correct,because i copied it from another page & removed some items etc.
I have an excel sheet of which i would like to copy a specific range, then save that range as a pdf file on the desktop.
When the file is saved it just needs to be called LR CODES
The range to copy is A1:K16
I have the code below but not entirely sure its correct,because i copied it from another page & removed some items etc.
Code:
Private Sub CommandButton1_Click() Dim strFileName As String
strFileName = "C:\Users\Ian\Desktop\ ".pdf"
If Dir(strFileName) <> vbNullString Then
MsgBox "SHEET " & " WAS NOT SAVED AS IT ALLREADY EXISTS", vbCritical + vbOKOnly
Exit Sub
End If
With ActiveSheet
.PageSetup.PrintArea = "$A$1:$K$16"
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
MsgBox "SHEET " & " WAS SAVED SUCCESSFULLY", vbInformation + vbOKOnly
End With
End Sub