pdf file

M

ml

I have read a few of your posts but not sure if any of those implied to what
I needed. Here's my question

I have about 20 worksheets/tabs in my workbook. I want to print/save them
in pdf format. All will be saved in the same location but each will have its
own file name base on the tab name (Dept A, Dept B, Dept C, etc). Can this
be possibly done? Please help.

Thanks,
ml
 
G

Gord Dibben

Assuming you are running Excel 2007

Sub Save_Sheets_As_PDF()
Dim w As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each w In ActiveWorkbook.Worksheets
w.Copy
With ActiveWorkbook
.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Program Files\Microsoft Office\2007exceldata" _
& "\" & w.Name & ".pdf"
.Close
End With
Next w
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP
 
M

ml

Thank you so much! Works like a charm.

Gord Dibben said:
Assuming you are running Excel 2007

Sub Save_Sheets_As_PDF()
Dim w As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each w In ActiveWorkbook.Worksheets
w.Copy
With ActiveWorkbook
.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Program Files\Microsoft Office\2007exceldata" _
& "\" & w.Name & ".pdf"
.Close
End With
Next w
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top