Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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, |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
setPrinter()
No parens. Just: setPrinter -- Jim "Janis" wrote in message ... 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, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
calling procedure | Excel Programming | |||
Calling sub procedure | Excel Programming | |||
Calling a procedure in a procedure | Excel Programming | |||
Calling a procedure in a procedure | Excel Programming | |||
Calling a procedure in a procedure | Excel Programming |