LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default Error using a macro to print multiple pages.

Hello,

I am fairly new to all this macro stuff. I have a macro that keeps
giving me an error only after I place protections on the sheets and
workbook. The macro is triggered by a command button (commandButton1).
The third page in my script is hidden, the other two are not. Ranges
are defined on the first two and they print just fine. Third one has a
formula which used to work but doesn't now. I have tried to figure out
why it has gone awry, and failed. Any help would be appreciated. Here
is the code:


Private Sub CommandButton1_Click()

' Hide_Print_Unhide Macro
' Macro recorded 5/5/2006 by Robert Lizak
'
Dim cell As Range
Dim myPwd As String


myPwd = "secret"


Application.ScreenUpdating = False

Sheets("Stats").PageSetup.PrintArea = "$A$1:$R$46"
Sheets("Stats").PrintPreview

Sheets("Equipment & Background").PageSetup.PrintArea = "$A$1:$F$46"
Sheets("Equipment & Background").PrintPreview

Sheets("Print Sheet").Active
ActiveSheet.Unprotect Password:=myPwd
Sheets("Print Sheet").Visible = True
With Sheets("Print Sheet")
For Each cell In .Range("A1:A712")
If cell.Value = "" Then cell.EntireRow.Hidden = True
Next cell
.PrintPreview
.Range("A1:A712").EntireRow.Hidden = False
.Visible = False
ActiveSheet.Protect Password:=myPwd
End With
Application.ScreenUpdating = True
'
End Sub

runtime error '438'
Object doesn't support this property or method.


-Robert Lizak-

 
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
Print all charts in a workbook (multiple worksheets) aewsaws Charts and Charting in Excel 4 May 12th 23 03:45 AM
Print multiple A5 pages on A4 paper Chirag Dedhia Excel Discussion (Misc queries) 4 April 24th 06 07:25 PM
Should all pages in a workbook print in color? Billy Excel Discussion (Misc queries) 1 March 21st 06 08:51 AM
Pivot Table macro to set print area and print details of drill down data Steve Haskins Excel Discussion (Misc queries) 2 December 28th 05 04:59 PM
Macro to open print window and set to print entire workbook retseort Excel Discussion (Misc queries) 1 October 27th 05 11:00 PM


All times are GMT +1. The time now is 01:41 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"