Excel VB Printing Error

rskalenza

New Member
Joined
Sep 26, 2006
Messages
1
I have an excel file open in Internet Explorer and when I try to use a print button for users to set which printer they would like to print to on the local network, the following error occurs trying to execute the code below. The error occurs only when the document is viewed in the web browser. Any time the document is opened with excel, the code works fine. Anyone had this error before and know a work around?

Run-time error '91'
Object variable or With block variable not set


Private Sub CommandButton1_Click()
Dim sPrinter As String
sPrinter = ComboBox1.Value
*****The error occurs on the next line*******
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
sPrinter, Collate:=True
UserForm3.Hide
End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,171,063
Messages
5,873,561
Members
432,984
Latest member
WilMel

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
Top