Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mia Mia is offline
external usenet poster
 
Posts: 101
Default Printing macro i network

I´m trying to program a macro for printing. The problem is that we are
working in a network and when I selceting a printer it does not work for my
colleges. What shall I do?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Printing macro i network

You could post your code and a few more datails about what you are trying to
achieve.

--
urkec


"Mia" wrote:

I´m trying to program a macro for printing. The problem is that we are
working in a network and when I selceting a printer it does not work for my
colleges. What shall I do?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Printing macro i network

Hi Mia

The Ne number of a printer can be different for every user

You can try this to print to for example the Adobe PDF printer

Sub Test()
Dim str As String
Dim strNetworkPrinter As String
str = Application.ActivePrinter

strNetworkPrinter = GetFullNetworkPrinterName("Adobe PDF")
If Len(strNetworkPrinter) 0 Then
Application.ActivePrinter = strNetworkPrinter
ActiveSheet.PrintOut
End If

Application.ActivePrinter = str
End Sub


Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String
Dim strCurrentPrinterName As String, strTempPrinterName As String, i As Long
strCurrentPrinterName = Application.ActivePrinter
i = 0
Do While i < 100
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i, "00") & ":"
On Error Resume Next ' try to change to the network printer
Application.ActivePrinter = strTempPrinterName
On Error GoTo 0
If Application.ActivePrinter = strTempPrinterName Then
GetFullNetworkPrinterName = strTempPrinterName
i = 100 ' makes the loop end
End If
i = i + 1
Loop
Application.ActivePrinter = strCurrentPrinterName ' change back to the original printer
End Function




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mia" wrote in message ...
I´m trying to program a macro for printing. The problem is that we are
working in a network and when I selceting a printer it does not work for my
colleges. What shall I do?


  #4   Report Post  
Posted to microsoft.public.excel.programming
Mia Mia is offline
external usenet poster
 
Posts: 101
Default Printing macro i network

Thank you Ron,

I have tryed doing as you instructed, but it doesent print, do you know what
I have done wrong?

Thank you in advance.

BR
Mia




Sub menyskrivoffert()
'
' menyskrivoffert Makro
Sheets("Offert MF").Select

Dim str As String

Dim strNetworkPrinter As String
str = Application.ActivePrinter

strNetworkPrinter = GetFullNetworkPrinterName("\\Server01\NRG DSc428 PCL
6 Färg på Ne07:")

If Len(strNetworkPrinter) 0 Then
Application.ActivePrinter = strNetworkPrinter

ActiveWindow.SelectedSheets.PrintOut Copies:=1

End If

Application.ActivePrinter = str

Sheets("Meny").Select
End Sub


Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String
Dim strCurrentPrinterName As String, strTempPrinterName As String, i As
Long
strCurrentPrinterName = Application.ActivePrinter
i = 0
Do While i < 100
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i,
"00") & ":"
On Error Resume Next ' try to change to the network printer
Application.ActivePrinter = strTempPrinterName
On Error GoTo 0
If Application.ActivePrinter = strTempPrinterName Then
GetFullNetworkPrinterName = strTempPrinterName
i = 100 ' makes the loop end
End If
i = i + 1
Loop
Application.ActivePrinter = strCurrentPrinterName ' change back to
the original printer
End Function




"Ron de Bruin" skrev:

Hi Mia

The Ne number of a printer can be different for every user

You can try this to print to for example the Adobe PDF printer

Sub Test()
Dim str As String
Dim strNetworkPrinter As String
str = Application.ActivePrinter

strNetworkPrinter = GetFullNetworkPrinterName("Adobe PDF")
If Len(strNetworkPrinter) 0 Then
Application.ActivePrinter = strNetworkPrinter
ActiveSheet.PrintOut
End If

Application.ActivePrinter = str
End Sub


Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String
Dim strCurrentPrinterName As String, strTempPrinterName As String, i As Long
strCurrentPrinterName = Application.ActivePrinter
i = 0
Do While i < 100
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i, "00") & ":"
On Error Resume Next ' try to change to the network printer
Application.ActivePrinter = strTempPrinterName
On Error GoTo 0
If Application.ActivePrinter = strTempPrinterName Then
GetFullNetworkPrinterName = strTempPrinterName
i = 100 ' makes the loop end
End If
i = i + 1
Loop
Application.ActivePrinter = strCurrentPrinterName ' change back to the original printer
End Function




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mia" wrote in message ...
I´m trying to program a macro for printing. The problem is that we are
working in a network and when I selceting a printer it does not work for my
colleges. What shall I do?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Printing macro i network

I think I know the problem

First only fill in the name you see in the print dialog when you do Ctrl-P

strNetworkPrinter = GetFullNetworkPrinterName("\\Server01\NRG DSc428 PCL
6 Färg på Ne07:")



på is the same as on I think ?

In the function change on in this line to på
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i, "00") & ":"



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mia" wrote in message ...
Thank you Ron,

I have tryed doing as you instructed, but it doesent print, do you know what
I have done wrong?

Thank you in advance.

BR
Mia




Sub menyskrivoffert()
'
' menyskrivoffert Makro
Sheets("Offert MF").Select

Dim str As String

Dim strNetworkPrinter As String
str = Application.ActivePrinter

strNetworkPrinter = GetFullNetworkPrinterName("\\Server01\NRG DSc428 PCL
6 Färg på Ne07:")

If Len(strNetworkPrinter) 0 Then
Application.ActivePrinter = strNetworkPrinter

ActiveWindow.SelectedSheets.PrintOut Copies:=1

End If

Application.ActivePrinter = str

Sheets("Meny").Select
End Sub


Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String
Dim strCurrentPrinterName As String, strTempPrinterName As String, i As
Long
strCurrentPrinterName = Application.ActivePrinter
i = 0
Do While i < 100
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i,
"00") & ":"
On Error Resume Next ' try to change to the network printer
Application.ActivePrinter = strTempPrinterName
On Error GoTo 0
If Application.ActivePrinter = strTempPrinterName Then
GetFullNetworkPrinterName = strTempPrinterName
i = 100 ' makes the loop end
End If
i = i + 1
Loop
Application.ActivePrinter = strCurrentPrinterName ' change back to
the original printer
End Function




"Ron de Bruin" skrev:

Hi Mia

The Ne number of a printer can be different for every user

You can try this to print to for example the Adobe PDF printer

Sub Test()
Dim str As String
Dim strNetworkPrinter As String
str = Application.ActivePrinter

strNetworkPrinter = GetFullNetworkPrinterName("Adobe PDF")
If Len(strNetworkPrinter) 0 Then
Application.ActivePrinter = strNetworkPrinter
ActiveSheet.PrintOut
End If

Application.ActivePrinter = str
End Sub


Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String
Dim strCurrentPrinterName As String, strTempPrinterName As String, i As Long
strCurrentPrinterName = Application.ActivePrinter
i = 0
Do While i < 100
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i, "00") & ":"
On Error Resume Next ' try to change to the network printer
Application.ActivePrinter = strTempPrinterName
On Error GoTo 0
If Application.ActivePrinter = strTempPrinterName Then
GetFullNetworkPrinterName = strTempPrinterName
i = 100 ' makes the loop end
End If
i = i + 1
Loop
Application.ActivePrinter = strCurrentPrinterName ' change back to the original printer
End Function




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mia" wrote in message ...
I´m trying to program a macro for printing. The problem is that we are
working in a network and when I selceting a printer it does not work for my
colleges. What shall I do?






  #6   Report Post  
Posted to microsoft.public.excel.programming
Mia Mia is offline
external usenet poster
 
Posts: 101
Default Printing macro i network

It worked!

Thank yoy so much! You solved a lot for me!

BR
Mia





"Ron de Bruin" skrev:

I think I know the problem

First only fill in the name you see in the print dialog when you do Ctrl-P

strNetworkPrinter = GetFullNetworkPrinterName("\\Server01\NRG DSc428 PCL
6 Färg på Ne07:")



på is the same as on I think ?

In the function change on in this line to på
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i, "00") & ":"



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mia" wrote in message ...
Thank you Ron,

I have tryed doing as you instructed, but it doesent print, do you know what
I have done wrong?

Thank you in advance.

BR
Mia




Sub menyskrivoffert()
'
' menyskrivoffert Makro
Sheets("Offert MF").Select

Dim str As String

Dim strNetworkPrinter As String
str = Application.ActivePrinter

strNetworkPrinter = GetFullNetworkPrinterName("\\Server01\NRG DSc428 PCL
6 Färg på Ne07:")

If Len(strNetworkPrinter) 0 Then
Application.ActivePrinter = strNetworkPrinter

ActiveWindow.SelectedSheets.PrintOut Copies:=1

End If

Application.ActivePrinter = str

Sheets("Meny").Select
End Sub


Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String
Dim strCurrentPrinterName As String, strTempPrinterName As String, i As
Long
strCurrentPrinterName = Application.ActivePrinter
i = 0
Do While i < 100
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i,
"00") & ":"
On Error Resume Next ' try to change to the network printer
Application.ActivePrinter = strTempPrinterName
On Error GoTo 0
If Application.ActivePrinter = strTempPrinterName Then
GetFullNetworkPrinterName = strTempPrinterName
i = 100 ' makes the loop end
End If
i = i + 1
Loop
Application.ActivePrinter = strCurrentPrinterName ' change back to
the original printer
End Function




"Ron de Bruin" skrev:

Hi Mia

The Ne number of a printer can be different for every user

You can try this to print to for example the Adobe PDF printer

Sub Test()
Dim str As String
Dim strNetworkPrinter As String
str = Application.ActivePrinter

strNetworkPrinter = GetFullNetworkPrinterName("Adobe PDF")
If Len(strNetworkPrinter) 0 Then
Application.ActivePrinter = strNetworkPrinter
ActiveSheet.PrintOut
End If

Application.ActivePrinter = str
End Sub


Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String
Dim strCurrentPrinterName As String, strTempPrinterName As String, i As Long
strCurrentPrinterName = Application.ActivePrinter
i = 0
Do While i < 100
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i, "00") & ":"
On Error Resume Next ' try to change to the network printer
Application.ActivePrinter = strTempPrinterName
On Error GoTo 0
If Application.ActivePrinter = strTempPrinterName Then
GetFullNetworkPrinterName = strTempPrinterName
i = 100 ' makes the loop end
End If
i = i + 1
Loop
Application.ActivePrinter = strCurrentPrinterName ' change back to the original printer
End Function




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mia" wrote in message ...
I´m trying to program a macro for printing. The problem is that we are
working in a network and when I selceting a printer it does not work for my
colleges. What shall I do?




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Printing macro i network

You are welcome

If you use different language installations you can add code to test the country code and change "on" to ?

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mia" wrote in message ...
It worked!

Thank yoy so much! You solved a lot for me!

BR
Mia





"Ron de Bruin" skrev:

I think I know the problem

First only fill in the name you see in the print dialog when you do Ctrl-P

strNetworkPrinter = GetFullNetworkPrinterName("\\Server01\NRG DSc428 PCL
6 Färg på Ne07:")



på is the same as on I think ?

In the function change on in this line to på
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i, "00") & ":"



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mia" wrote in message ...
Thank you Ron,

I have tryed doing as you instructed, but it doesent print, do you know what
I have done wrong?

Thank you in advance.

BR
Mia




Sub menyskrivoffert()
'
' menyskrivoffert Makro
Sheets("Offert MF").Select

Dim str As String

Dim strNetworkPrinter As String
str = Application.ActivePrinter

strNetworkPrinter = GetFullNetworkPrinterName("\\Server01\NRG DSc428 PCL
6 Färg på Ne07:")

If Len(strNetworkPrinter) 0 Then
Application.ActivePrinter = strNetworkPrinter

ActiveWindow.SelectedSheets.PrintOut Copies:=1

End If

Application.ActivePrinter = str

Sheets("Meny").Select
End Sub


Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String
Dim strCurrentPrinterName As String, strTempPrinterName As String, i As
Long
strCurrentPrinterName = Application.ActivePrinter
i = 0
Do While i < 100
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i,
"00") & ":"
On Error Resume Next ' try to change to the network printer
Application.ActivePrinter = strTempPrinterName
On Error GoTo 0
If Application.ActivePrinter = strTempPrinterName Then
GetFullNetworkPrinterName = strTempPrinterName
i = 100 ' makes the loop end
End If
i = i + 1
Loop
Application.ActivePrinter = strCurrentPrinterName ' change back to
the original printer
End Function




"Ron de Bruin" skrev:

Hi Mia

The Ne number of a printer can be different for every user

You can try this to print to for example the Adobe PDF printer

Sub Test()
Dim str As String
Dim strNetworkPrinter As String
str = Application.ActivePrinter

strNetworkPrinter = GetFullNetworkPrinterName("Adobe PDF")
If Len(strNetworkPrinter) 0 Then
Application.ActivePrinter = strNetworkPrinter
ActiveSheet.PrintOut
End If

Application.ActivePrinter = str
End Sub


Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String
Dim strCurrentPrinterName As String, strTempPrinterName As String, i As Long
strCurrentPrinterName = Application.ActivePrinter
i = 0
Do While i < 100
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i, "00") & ":"
On Error Resume Next ' try to change to the network printer
Application.ActivePrinter = strTempPrinterName
On Error GoTo 0
If Application.ActivePrinter = strTempPrinterName Then
GetFullNetworkPrinterName = strTempPrinterName
i = 100 ' makes the loop end
End If
i = i + 1
Loop
Application.ActivePrinter = strCurrentPrinterName ' change back to the original printer
End Function




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mia" wrote in message ...
I´m trying to program a macro for printing. The problem is that we are
working in a network and when I selceting a printer it does not work for my
colleges. What shall I do?





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Printing macro i network

Hi Ron,
I just tried your programming and it worked for me, to print 1x copy.
Is it possible to have it print more then 1x copy? Or even better to have it
come up with a prompt to select the number of copies required?
Also is it possible to have the programming make it print double side?

Regards
Kevin.

"Ron de Bruin" wrote:

Hi Mia

The Ne number of a printer can be different for every user

You can try this to print to for example the Adobe PDF printer

Sub Test()
Dim str As String
Dim strNetworkPrinter As String
str = Application.ActivePrinter

strNetworkPrinter = GetFullNetworkPrinterName("Adobe PDF")
If Len(strNetworkPrinter) 0 Then
Application.ActivePrinter = strNetworkPrinter
ActiveSheet.PrintOut
End If

Application.ActivePrinter = str
End Sub


Function GetFullNetworkPrinterName(strNetworkPrinterName As String) As String
Dim strCurrentPrinterName As String, strTempPrinterName As String, i As Long
strCurrentPrinterName = Application.ActivePrinter
i = 0
Do While i < 100
strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i, "00") & ":"
On Error Resume Next ' try to change to the network printer
Application.ActivePrinter = strTempPrinterName
On Error GoTo 0
If Application.ActivePrinter = strTempPrinterName Then
GetFullNetworkPrinterName = strTempPrinterName
i = 100 ' makes the loop end
End If
i = i + 1
Loop
Application.ActivePrinter = strCurrentPrinterName ' change back to the original printer
End Function




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mia" wrote in message ...
I´m trying to program a macro for printing. The problem is that we are
working in a network and when I selceting a printer it does not work for my
colleges. What shall I do?



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
Printing on a network leerem Excel Discussion (Misc queries) 6 September 26th 08 07:36 PM
NETWORK (LAN) MACRO QUESTION: W XP Pro, SP-2 JingleRock Excel Programming 0 May 17th 06 05:17 PM
Network macro not working M Moore Excel Programming 1 March 27th 06 01:57 AM
macro to save to network jim hardwick[_2_] Excel Programming 1 August 22nd 05 07:11 PM
macro won't run from network Steve Simons Excel Discussion (Misc queries) 2 December 12th 04 01:41 AM


All times are GMT +1. The time now is 09:40 AM.

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"