Using a macro to print 1 sheet of a workbook to a PDF file

MLRTX

New Member
Joined
Jun 9, 2011
Messages
1
Greetings to all. This is my first post here but not my first visit by far. Over the last year I have used this forum to help me create a timesheet application for the company I work for. Let it be known that calling my skill level moderate would be gracious.

The application I have created works great...except for 1 thing. When an employee completed filling out the timesheet for the day, the Print button is pressed to run the macro below. The file is created and save exactly as intended exept that all 3 worksheets in the workbook are save in the PDF file. The main sheet for user interface, the worksheet with formulas, tables, etc. (neither of which need to be printed). And the timesheet template (that should print). The two added sheets are causing some storage issues on the server and some unwarranted ribbing from the cheap seats. I need to get rid of those 2 sheets.

I have tried various objects, print areas, cut and paste, delete worksheets etc. to no avail. Any help to print just the one sheet would be hugely appreciated.

Mike

========================================================
Sub SavePDF_Click()
'
'This macro prints the timesheet to the correct directory and filename as a PDF file
Dim StaticDirect As String
Dim WeekEndDirect As String
Dim DailyFile As String
Dim FileSaveDest As String

'Set the static part of the Directory path for saving the Daily Timesheet to a PDF file
StaticDirect = "C:\Time\"


'Set the value of the week ending part of the Directory path for saving the
'Daily Timesheet to a PDF file
WeekEndDirect = Range("WEndDate3").Value

'Set the value of the daily part of the filename
DailyFile = Range("Date3").Value


'Concatenate the Directory path and filename to create the Directory path and filename
'of the PDF file
FileSaveDest = StaticDirect & "WE " & WeekEndDirect & "\CPR Timesheet " & DailyFile

'Print and save the PDF file to the appropriate directory and filename
ActiveWorkbook.ExportAsFixedFormat xlTypePDF, FileSaveDest

End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,224,558
Messages
6,179,512
Members
452,920
Latest member
jaspers

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top