LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default help with calling a sub procedure, doesn't compile

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,
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
calling procedure Juggernath[_4_] Excel Programming 3 December 13th 05 12:40 PM
Calling sub procedure Yossi[_2_] Excel Programming 2 August 21st 05 02:01 PM
Calling a procedure in a procedure Norman Jones Excel Programming 8 August 20th 04 07:53 PM
Calling a procedure in a procedure N10 Excel Programming 2 August 18th 04 12:49 AM
Calling a procedure in a procedure Don Guillett[_4_] Excel Programming 1 August 17th 04 11:31 PM


All times are GMT +1. The time now is 08:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"