Excel VBA .Printout Method Fails

Colin Legg
08-23-2005, 03:02 PM
Hi all,

I have a very straightforward procedure to print every worksheet within the active workbook. It works correctly all of the time except for when I use it on one particular workbook.... and I really can't work out why!!

The VBA code is this:

Dim wSt As Worksheet
For Each wSt In ActiveWorkbook.Worksheets
wSt.PrintOut
Next wSt


The error message I am getting is this:
Run-time error '1004': Method 'PrintOut' of object '_Worksheet' failed

Can anyone give me some hints as to why this is happening with one particular workbook? I'm sure I must be overlooking something very basic. If not then I can attach the workbook for you to look at.

Thanks
Colin

Kluz
08-23-2005, 05:32 PM
The workbook may have Hidden or VeryHidden worksheets, these might give you an error. You might want to go with the workbook's .PrintOut Method and let Excel decide what sheets can be printed.

Colin Legg
08-24-2005, 08:42 AM
Ahhhhh.... you got it. Yes it had some hidden worksheets.... I didn't think of that. I'll use the workbook's printout method like you suggested - thanks a lot. :D

Colin

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum