ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run-Time error '91' (https://www.excelbanter.com/excel-programming/427706-re-run-time-error-91-a.html)

joel

Run-Time error '91'
 
Try selecting a printer from excel before running the macro. I have seen
some websites that specfically tell the user to select the printer before
activating a control button.

"ajayb" wrote:

Hi,

I have an Excel workbook that works fine when opening in an Excel window.
This workbook needs to sit on our intranet though. When opening it opens in
an Internet Explorer Window. The file works ok except that the following
code which is attached to a button on a form:

Private Sub FelipeButton32_Click()
ActiveSheet.PageSetup.PrintArea = "$AA$13:$Ad$16"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, collate:=True
ActiveSheet.PageSetup.PrintArea = "$B$2:$k$175"
End Sub

Causes:
Run-Time error '91' - Object variable or With block variable not set.

Yet the routine doesn't cause the problem when opened in Excel normally.
Can anyone tell me why at all?

Thanks

Andy



All times are GMT +1. The time now is 02:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com