run-time error 1004--macro help

royhern

Board Regular
Joined
Feb 21, 2002
Messages
158
I have recorded a macro to print select sheets in a workbook and have hidden the sheets but when i want to print the specified sheets i get this error:

Run-time error '1004'

select method of sheets class failed

Any ideas on how to resolve this error besides having the sheets be visible ?
This message was edited by royhern on 2002-09-25 18:07
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi royhern,
Please show us your code, I guess you have to make sheets visible before print method.
 
Upvote 0
The steps i took were first record the macro having the sheets visible and i used ASAP utilities to hide the sheets. The macro works great when the sheets are visible but the error is generated after i make the sheets invisible and run the macro for printing.

Hope this info helps!!
 
Upvote 0
You can prevent the user from seeing what's happening by using:

Application.ScreenUpdating = False

before you do your stuff.

Reset it with:

Application.ScreenUpdating = True

at the end.
 
Upvote 0
Well still it doesn't work but i think it is because i could be doing wrong. this is the code ...can anyone tell me how can i fix this to get the printing done.
Sub SM4PGPMPPRINTING()
'
' SM4PGPMPPRINTING Macro
' Macro recorded 9/24/2002 by Administrator
'

'
Sheets(Array("Cover pg 1", "Mg Goal Pg & Mid-Final", _
"Guiding Values Goal & Mid-Final", "Mg Career dev & Final Rating")).Select
Sheets("Cover pg 1").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Sheets("Cover pg 1").Select
Range("I42:K42").Select
End Sub

Not really sure where Andrews suggestions of entry could go.

Thanks, Roy
This message was edited by royhern on 2002-09-26 15:00
 
Upvote 0
Recording a macro produces a lot of unnecessary code. You can reduce your code to this:

Sheets(Array("Cover pg 1", "Mg Goal Pg & Mid-Final", _
"Guiding Values Goal & Mid-Final", "Mg Career dev & Final Rating")).PrintOut Copies:=2
End Sub

If you want to include the screen update code, you just turn off updating before your code, then turn it on after your code, like this:

application.screenupdating = false
Sheets(Array("Cover pg 1", "Mg Goal Pg & Mid-Final", _
"Guiding Values Goal & Mid-Final", "Mg Career dev & Final Rating")).PrintOut Copies:=2
application.screenupdating = true
End Sub
 
Upvote 0
Team, i think i might be doing something wrong because i am still getting the error when trying to print after the sheets are hidden. This is the code...

Sub SM4PGPMPPRINTING()
'
' SM4PGPMPPRINTING Macro
' Macro recorded 9/24/2002 by Administrator
'

'
Application.ScreenUpdating = False
Sheets(Array("Cover pg 1", "Mg Goal Pg & Mid-Final", _
"Guiding Values Goal & Mid-Final", "Mg Career dev & Final Rating")).Select
Sheets("Cover pg 1").Activate
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Sheets("Cover pg 1").Select
Range("I42:K42").Select
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,078
Latest member
skydd

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