#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 53
Default Print code

Hello,
I have a marco recorded to print a selection of sheets. The printer being
used is on a network and not my default printer. When I create the code on
my PC, it works fine, but as soon as another user tries to use the code from
their PC it won't work. Code is attached below, when I tried to create the
code on another PC, the section Ne04 in both lines is the only thing that
changed. Is there a common statement that could make this work regardless of
the PC from which I'm opening the file?

Application.ActivePrinter = "\\mrafp1\MRA-ADMINCP1 on Ne04:"
ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,""\\mrafp1\MRA-ADMINCP1 on
Ne04:"",,TRUE,,FALSE)"

--
Thank you for your time!
John
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Print code

First, I didn't go back to the xlm help to find out what those parms mean in the
xl4 macro line. In fact, I'd record a new macro that gave me the code in
"normal" VBA.

But if you don't want to try that, you could try:

Option Explicit
Sub testme()
Dim iCtr As Long
Dim FoundIt As Boolean
Dim CurPrinter As String

CurPrinter = Application.ActivePrinter

FoundIt = False
For iCtr = 0 To 99
On Error Resume Next
Application.ActivePrinter = "\\mrafp1\MRA-ADMINCP1 on Ne" _
& Format(iCtr, "00") & ":"
If Err.Number = 0 Then
FoundIt = True
Exit For
Else
'keep looking
Err.Clear
End If
Next iCtr
On Error GoTo 0

If FoundIt = False Then
MsgBox "No printer close to that name"
Else
'do the real work
ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,""" & ActivePrinter.Name _
& """,,TRUE,,FALSE)"
'and change it back
Application.ActivePrinter = CurPrinter
End If
End Sub

=======
If you're just printing the activesheet, the code could be as simple as:


If FoundIt = False Then
MsgBox "No printer close to that name"
Else
'do the real work
activesheet.printout
'and change it back
Application.ActivePrinter = CurPrinter
End If
Very Basic User wrote:

Hello,
I have a marco recorded to print a selection of sheets. The printer being
used is on a network and not my default printer. When I create the code on
my PC, it works fine, but as soon as another user tries to use the code from
their PC it won't work. Code is attached below, when I tried to create the
code on another PC, the section Ne04 in both lines is the only thing that
changed. Is there a common statement that could make this work regardless of
the PC from which I'm opening the file?

Application.ActivePrinter = "\\mrafp1\MRA-ADMINCP1 on Ne04:"
ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,""\\mrafp1\MRA-ADMINCP1 on
Ne04:"",,TRUE,,FALSE)"

--
Thank you for your time!
John


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Print code

I refered to the printer's name incorrectly.

It should have been:

ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,""" & Application.ActivePrinter _
& """,,TRUE,,FALSE)"




Dave Peterson wrote:

First, I didn't go back to the xlm help to find out what those parms mean in the
xl4 macro line. In fact, I'd record a new macro that gave me the code in
"normal" VBA.

But if you don't want to try that, you could try:

Option Explicit
Sub testme()
Dim iCtr As Long
Dim FoundIt As Boolean
Dim CurPrinter As String

CurPrinter = Application.ActivePrinter

FoundIt = False
For iCtr = 0 To 99
On Error Resume Next
Application.ActivePrinter = "\\mrafp1\MRA-ADMINCP1 on Ne" _
& Format(iCtr, "00") & ":"
If Err.Number = 0 Then
FoundIt = True
Exit For
Else
'keep looking
Err.Clear
End If
Next iCtr
On Error GoTo 0

If FoundIt = False Then
MsgBox "No printer close to that name"
Else
'do the real work
ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,""" & ActivePrinter.Name _
& """,,TRUE,,FALSE)"
'and change it back
Application.ActivePrinter = CurPrinter
End If
End Sub

=======
If you're just printing the activesheet, the code could be as simple as:

If FoundIt = False Then
MsgBox "No printer close to that name"
Else
'do the real work
activesheet.printout
'and change it back
Application.ActivePrinter = CurPrinter
End If
Very Basic User wrote:

Hello,
I have a marco recorded to print a selection of sheets. The printer being
used is on a network and not my default printer. When I create the code on
my PC, it works fine, but as soon as another user tries to use the code from
their PC it won't work. Code is attached below, when I tried to create the
code on another PC, the section Ne04 in both lines is the only thing that
changed. Is there a common statement that could make this work regardless of
the PC from which I'm opening the file?

Application.ActivePrinter = "\\mrafp1\MRA-ADMINCP1 on Ne04:"
ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,""\\mrafp1\MRA-ADMINCP1 on
Ne04:"",,TRUE,,FALSE)"

--
Thank you for your time!
John


--

Dave Peterson


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 53
Default Print code

Thank you Dave,

Actually the full code is...

If I understand you correctly, I would add the long code in place of the two
lines that contain the NE04? Is that correct?

Thanks for your time!

Sub PrintAll()
'
' PrintAll Macro
'

'
Sheets("Line 1 Graph ").Select
Range("A1").Select
Application.ActivePrinter = "\\mrafp1\MRA-ADMINCP1 on Ne04:"
ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,""\\mrafp1\MRA-ADMINCP1 on
Ne04:"",,TRUE,,FALSE)"
Sheets("Line 3 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
Sheets("Line 6 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
Sheets("Line 9 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
Sheets("Line 10 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
ActiveWindow.ScrollWorkbookTabs Sheets:=1
Sheets("Line 2 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
Sheets("Line 5 Graph ").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
Sheets("Line 7 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
Sheets("Line 8 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Navigation").Select
End Sub

--
Thank you for your time!
John


"Dave Peterson" wrote:

First, I didn't go back to the xlm help to find out what those parms mean in the
xl4 macro line. In fact, I'd record a new macro that gave me the code in
"normal" VBA.

But if you don't want to try that, you could try:

Option Explicit
Sub testme()
Dim iCtr As Long
Dim FoundIt As Boolean
Dim CurPrinter As String

CurPrinter = Application.ActivePrinter

FoundIt = False
For iCtr = 0 To 99
On Error Resume Next
Application.ActivePrinter = "\\mrafp1\MRA-ADMINCP1 on Ne" _
& Format(iCtr, "00") & ":"
If Err.Number = 0 Then
FoundIt = True
Exit For
Else
'keep looking
Err.Clear
End If
Next iCtr
On Error GoTo 0

If FoundIt = False Then
MsgBox "No printer close to that name"
Else
'do the real work
ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,""" & ActivePrinter.Name _
& """,,TRUE,,FALSE)"
'and change it back
Application.ActivePrinter = CurPrinter
End If
End Sub

=======
If you're just printing the activesheet, the code could be as simple as:


If FoundIt = False Then
MsgBox "No printer close to that name"
Else
'do the real work
activesheet.printout
'and change it back
Application.ActivePrinter = CurPrinter
End If
Very Basic User wrote:

Hello,
I have a marco recorded to print a selection of sheets. The printer being
used is on a network and not my default printer. When I create the code on
my PC, it works fine, but as soon as another user tries to use the code from
their PC it won't work. Code is attached below, when I tried to create the
code on another PC, the section Ne04 in both lines is the only thing that
changed. Is there a common statement that could make this work regardless of
the PC from which I'm opening the file?

Application.ActivePrinter = "\\mrafp1\MRA-ADMINCP1 on Ne04:"
ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,""\\mrafp1\MRA-ADMINCP1 on
Ne04:"",,TRUE,,FALSE)"

--
Thank you for your time!
John


--

Dave Peterson
.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Print code

Not quite all the code--but most of it.

Don't forget to read my followup with the correction.

Very Basic User wrote:

Thank you Dave,

Actually the full code is...

If I understand you correctly, I would add the long code in place of the two
lines that contain the NE04? Is that correct?

Thanks for your time!

Sub PrintAll()
'
' PrintAll Macro
'

'
Sheets("Line 1 Graph ").Select
Range("A1").Select
Application.ActivePrinter = "\\mrafp1\MRA-ADMINCP1 on Ne04:"
ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,""\\mrafp1\MRA-ADMINCP1 on
Ne04:"",,TRUE,,FALSE)"
Sheets("Line 3 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
Sheets("Line 6 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
Sheets("Line 9 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
Sheets("Line 10 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
ActiveWindow.ScrollWorkbookTabs Sheets:=1
Sheets("Line 2 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
Sheets("Line 5 Graph ").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
Sheets("Line 7 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
Sheets("Line 8 Graph").Select
Range("A1").Select
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Navigation").Select
End Sub

--
Thank you for your time!
John

"Dave Peterson" wrote:

First, I didn't go back to the xlm help to find out what those parms mean in the
xl4 macro line. In fact, I'd record a new macro that gave me the code in
"normal" VBA.

But if you don't want to try that, you could try:

Option Explicit
Sub testme()
Dim iCtr As Long
Dim FoundIt As Boolean
Dim CurPrinter As String

CurPrinter = Application.ActivePrinter

FoundIt = False
For iCtr = 0 To 99
On Error Resume Next
Application.ActivePrinter = "\\mrafp1\MRA-ADMINCP1 on Ne" _
& Format(iCtr, "00") & ":"
If Err.Number = 0 Then
FoundIt = True
Exit For
Else
'keep looking
Err.Clear
End If
Next iCtr
On Error GoTo 0

If FoundIt = False Then
MsgBox "No printer close to that name"
Else
'do the real work
ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,""" & ActivePrinter.Name _
& """,,TRUE,,FALSE)"
'and change it back
Application.ActivePrinter = CurPrinter
End If
End Sub

=======
If you're just printing the activesheet, the code could be as simple as:


If FoundIt = False Then
MsgBox "No printer close to that name"
Else
'do the real work
activesheet.printout
'and change it back
Application.ActivePrinter = CurPrinter
End If
Very Basic User wrote:

Hello,
I have a marco recorded to print a selection of sheets. The printer being
used is on a network and not my default printer. When I create the code on
my PC, it works fine, but as soon as another user tries to use the code from
their PC it won't work. Code is attached below, when I tried to create the
code on another PC, the section Ne04 in both lines is the only thing that
changed. Is there a common statement that could make this work regardless of
the PC from which I'm opening the file?

Application.ActivePrinter = "\\mrafp1\MRA-ADMINCP1 on Ne04:"
ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,""\\mrafp1\MRA-ADMINCP1 on
Ne04:"",,TRUE,,FALSE)"

--
Thank you for your time!
John


--

Dave Peterson
.


--

Dave Peterson
Reply
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
Print Code aftamath77 Excel Discussion (Misc queries) 3 October 6th 08 03:49 PM
Print Code Scott Excel Discussion (Misc queries) 2 September 8th 08 04:36 PM
Print Code Sunday88310 Excel Discussion (Misc queries) 2 August 3rd 07 07:20 AM
Print Code Chey Excel Discussion (Misc queries) 1 April 13th 07 08:18 PM
Leading zero in zip code won't print J Mac Excel Discussion (Misc queries) 7 September 1st 05 12:07 AM


All times are GMT +1. The time now is 10:56 PM.

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

About Us

"It's about Microsoft Excel"