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
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