Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-13-2011, 06:11 AM
shabbaranks shabbaranks is offline How do I specify which sheet to save as PDF? Windows 7 64bit How do I specify which sheet to save as PDF? Office 2007
Advanced Beginner
How do I specify which sheet to save as PDF?
 
Join Date: Mar 2011
Posts: 89
shabbaranks is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 09-13-2011, 09:41 PM
Catalin.B Catalin.B is offline How do I specify which sheet to save as PDF? Windows Vista How do I specify which sheet to save as PDF? 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
  #3  
Old 09-14-2011, 12:40 AM
shabbaranks shabbaranks is offline How do I specify which sheet to save as PDF? Windows 7 64bit How do I specify which sheet to save as PDF? Office 2007
Advanced Beginner
How do I specify which sheet to save as PDF?
 
Join Date: Mar 2011
Posts: 89
shabbaranks is on a distinguished road
Default

Great -thanks a lot .
Reply With Quote
  #4  
Old 09-14-2011, 09:19 PM
jolivanes jolivanes is offline How do I specify which sheet to save as PDF? Windows XP How do I specify which sheet to save as PDF? Office 2007
Advanced Beginner
 
Join Date: Sep 2011
Posts: 93
jolivanes will become famous soon enough
Default

Or adapt attached file
Attached Files
File Type: zip VB Select Sheets To Print With Userform.zip (28.7 KB, 12 views)
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I specify which sheet to save as PDF? 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
How do I specify which sheet to save as PDF? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 07:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft