#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default PDF Save as

I am using the following code to print each unique sheet in a workbook but
would like to link to a cell for a filename rather than having to type this
information in, the code i use is as follows;

Sub PrintAllSheets()
'
Dim M As Long, N As Long, Firstsht As Long, Lastsht As Long, Sheet As
Object
'
Lastsht = Sheets.Count
M = 0: N = Lastsht
'
For Each Sheet In Sheets
If Not Sheet.Visible Then N = N - 1
If Sheet.Visible And Sheet.Type = xlWorksheet Then
If WorksheetFunction.CountA(Sheet.UsedRange) = 0 Then
N = N - 1
End If
End If
Next
'
For Firstsht = 1 To Lastsht
'
If Sheets(Firstsht).Visible = True Then
'
If Not TypeName(Sheets(Firstsht)) = "Chart" Then
If WorksheetFunction.CountA(Sheets(Firstsht).UsedRang e) < 0
Then
M = M + 1
GoSub DoPrint
End If
Else 'else it's a chart
M = M + 1
GoSub DoPrint
End If
'
End If
'
Next 'Firstsht
Exit Sub
DoPrint:
With Sheets(Firstsht).PageSetup
.CenterHeader = "&F!&A"
.CenterFooter = "Page " & CStr(M) & " of " & N
.RightFooter = "©" & CStr(Year(Date))
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
With Application
.EnableEvents = False
Sheets(Firstsht).PrintOut
.EnableEvents = True
End With
Return
End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save, save as, page setup dimmed out in unprotected excel sheet? ccKeithJ Excel Discussion (Misc queries) 3 December 14th 07 07:07 PM
SAVE and SAVE AS options disappeared from the drop down FILE menu [email protected] Excel Discussion (Misc queries) 2 July 12th 07 09:14 AM
Save As and save current numbers not the actual formulas and links Frank Menard Excel Discussion (Misc queries) 2 November 9th 06 09:18 PM
how to get disk icon on save button of save as dialog like 2000 RichT Excel Discussion (Misc queries) 2 March 9th 06 08:13 PM
when i save xls file, debug script is running and canno't save fil Imtiaz Excel Discussion (Misc queries) 1 July 16th 05 03:47 PM


All times are GMT +1. The time now is 04:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"