#1
|
|||
|
|||
How do I specify which sheet to save as PDF?
Hi All,
Ive got my macro working to print active sheet to pdf but I would like to create buttons which specify a perticular sheet - can anyone tell me how please? Code:
Sub Convert2PDF() ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ sFileName, Quality _ :=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _ OpenAfterPublish:=True End Sub |
#2
|
|||
|
|||
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 |
#3
|
|||
|
|||
Great -thanks a lot .
|
#4
|
|||
|
|||
Or adapt attached file
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to save as pdf with ability to choose save as folder | rvessio | Word VBA | 4 | 07-25-2016 12:37 PM |
Reading Values from another sheet | Raabi | Excel | 2 | 05-20-2011 02:14 AM |
PowerPoint Crashes every time I try to save/save as | Crimson_Ninja | PowerPoint | 0 | 05-04-2011 01:54 PM |
Delete sheet through VBA | Salim Khan | Excel | 1 | 08-30-2010 09:11 AM |
copy cell from sheet 2 to sheet 3 macro | slipperyjim | Excel Programming | 1 | 02-18-2010 01:31 AM |