help with calling a sub procedure, doesn't compile

J

Janis

I want to use the sub procedure below and call the setPrinter() procedure in
different macros. It is an error handler because the network the printer is
on is dyanamic. I want to use this procedure to set the printer string in
all my macros.

The problem is I'm not calling the setPrinter() procedure correctly and I
get an error. Since it would be the activesheet we are doing the pagesetup
on is that why it doesn't compile or do I have the syntax wrong? Is it
because it doesn't know where the active sheet is when I call it from the
procedure? The error handler works fine if I run it in the code without it
being a sub procedure but it would be nice to not have to add that to every
print macro. It seems like after the Psetup

Application.ActiveSheet.UsedRange
Set AC_Sheet = Application.ActiveSheet
Set AW = Application.ActiveWorkbook
AW_Name = AW.Name
Set UsedRange1 = AC_Sheet.UsedRange
UsedRows1 = UsedRange1.Rows.Count
UsedCol1 = UsedRange1.Columns.Count

SubTotalRows = GetSubTotalRows() 'added by janis

Set Psetup = ActiveSheet.PageSetup

setPrinter()


Application.ActivePrinter = "\\myregion\myPrinter on Ne0" & Counter
& ":"
PS48x11
Application.ScreenUpdating = False
ActiveSheet.ResetAllPageBreaks

With ActiveSheet.PageSetup
.PrintArea = ""
.PrintTitleRows = "$1:$11"
.PrintTitleColumns = ""
.Zoom = False
---------------function--------------


Public Sub setPrinter()
Dim Counter As Integer
' This function loops through the number 1-9 because the _
network on the printer is not stationary _
but changes from Network 1 - 9.
On Error Resume Next
For Counter = 1 To 9
Err.Clear
Application.ActivePrinter = "\\myregion\myprinter on Ne0" & Counter & ":"
If Err.Number = 0 Then Exit For
Next
If Err.Number <> 0 Then MsgBox "the command to print has an error."
End Sub

tia,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top