View Single Post
 
Old 09-13-2011, 09:41 PM
Catalin.B Catalin.B is offline Windows Vista Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

in line 2 of your code, instead of: ActiveSheet.ExportAsFixedFormat
change to : Sheets("Sheet1").ExportAsFixedFormat
Rename Sheet1 to match your sheet name..
copy macro as many times as sheets number
in each copy rename sheet to convert, and assign the macros to appropriate buttons (butons created via Developer-controls-insert-buton...)
or make your macro ask to enter sheet name to convert...
Code:
Sub mySheetNameSelection() 
      Dim mySheetName As String          
On Error GoTo error_NoSheet     
mySheetName = InputBox("Enter Sheet Name") 
    Sheets(mySheetName).ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ 
sFileName, Quality _
 :=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
 OpenAfterPublish:=True     
On Error GoTo 0          
Exit Sub      
error_NoSheet: 
    If Err.Number = 9 Then         
MsgBox "No such sheet name exists"         
Exit Sub     
Else         
MsgBox Err.Number & vbCrLf & Err.Description     
End If      
End Sub
Reply With Quote