See Related Forum Messages: Follow the Links Below to View Complete Thread
How Can I Change The Default Printer At Runtime To Use It With Printer.print Command?
Hi everyone,
I have a little application which uses printer.print command to do some print jobs, of course there are some other things that I print using Data Reports.
When my application starts, I think it instantiates printer object with the default printer (lx300). Once the application is started, there are some options that use printer.print, but there are options that use printer.print too but I need to print them in another printer (ip1000). I have a common dialog that lets me choose the printer, and when I choose ip1000 every printer.print call goes to lx300. I assume there's no way to "reinstantiate" printer object to print in ip1000.
Also, when I close my application ip1000 becomes my default printer. Does the common dialog can select a printer without changing the Windows default printer like Word, Excel. do?
Thanks a lot for your help
How Can I Change The Default Printer At Runtime To Use It With Printer.print Command?
Hi everyone,
I have a little application which uses printer.print command to do some print jobs, of course there are some other things that I print using Data Reports.
When my application starts, I think it instantiates printer object with the default printer (lx300). Once the application is started, there are some options that use printer.print, but there are options that use printer.print too but I need to print them in another printer (ip1000). I have a common dialog that lets me choose the printer, and when I choose ip1000 every printer.print call goes to lx300. I assume there's no way to "reinstantiate" printer object to print in ip1000.
Also, when I close my application ip1000 becomes my default printer. Does the common dialog can select a printer without changing the Windows default printer like Word, Excel. do?
Thanks a lot for your help
Print To A Non-default Printer
I have a network printer installed on a print server. From my workstation, using a simple VB program, I'm trying to print to this printer. The printer is not my Default (in fact is not even shared on the server!). When I'm running this code:
Code:
Dim thePrinter As Printer
thePrinter.DeviceName = "\SERVERPrinter1"
Set Printer = thePrinter
I'm getting a "Compile error: Wrong number of arguments or invalid property assignment". Can anyone point out why it's not working?
Thanks,
poli
Print To Non-default Printer
I have a label-printing program that I want to print to a non-default printer. Each label is printed using "PrintForm". I do not want my user to have to change the setting for the default printer each time she needs to print a label.
What is the simplest way to change the printer in code?
Thanks in advance.
Print In The Default Printer From VBA.
I am developing a VBA embeded code in an Excel workbook and I would like that it send some phrases to be print by the default printer after the user click a button. If I am not confused, I remember that very old versions of Basic used to have the LPrint command but it seems that VBA does not support this command. Is there some equivalent command??
Print To A Non Default Printer
I currently have two systems. Each has a VB application that gets run on a schedule to print a data report to the default printer without any user interaction. I am tasked with combining these two older systems into one bigger system. Of course the problem is that I cannot have two default printers...and I cannot use the Print Dialog as there is no user interaction. Does anyone have a direction they can point me, sample code, etc...that would give me insight in how to tell a Printout to go to a specified printer. I would rather not have the code change the default printer, as a timing issue will come into play as I move more systems onto this same big server.
Print To A Special Printer Instead Of The Default
Hy,
Right now i print everything to the default printer. Ore i can place a dialog on the screen so the user can select a printer with the line below:
Call frmMain.dlgCommonDialog.ShowPrinter
But i like to print it not to the default printer but to a printer called Primo
Is that possible ? and how?
I use VB 6.0
Thanks a lot!
Need To Print To A Specific Non Default Printer
I have written an app that prints barcodes from a SQL db via a GUI. When the user prints the barcodes, I want the barcode to automatically print to a printer I specify via an INI file. I have everything else working. The app currently open the printers box so the user can select which printer to print to, num copies etc.
How do a specify in my code the printer I want to print to without prompting the user with the printers dialogue?
Much Thanks,
Dave
DataReport Print Not In Default Printer
I have this problem: on my pc there are 2 VB application each with the DataReport.
The first, print on the default printer, the second must print on another network printer.
I found much example to set a printer like default printer , but I need to select from code the printer.
The print request is an asynchronous event and so i can change the defualt printer because there is the risk to create error.
If I show the report, is possible to select the printer (with the printer dialog). I need to make the same thing from code.
Help me please!!!
Thanks
Print A Form In Specific Printer (not To The Default)
I have more than 3 printer drivers installed in a machine.
Let say that the DEFAULT printer name is : hp deskjet 845c
I made a program that prints some barcodes with a SATO
driver, printer name is : SATO M-8400RV
Everytime I have to print, I have to change the default
printer and then print the barcodes or on the other hand
change the default again to print with the HP 845c.
How can I print a form in a SPECIFIC printer without having
to do that stupid manual thing ? I just use the form1.printform
command to print and works fine for the work to be done. I just want to
avoid that...change default all the time.
Default driver name : hp deskjet 845c
Barcode driver name : SATO M-8400RV
Default is connected with LPT1 and SATO with LPT2 (in printer settings)
Thanx a lot for your time.
Set Printer Defaults For Print Job And Return To Default
In a VB 6 application run in Win XP with Crystal Reports 9 RDC for reporting, the printer I am using for a specific print job allows duplex printing. I've included a printer selection button on a form for setting print parameters and allowing the user to select a specific printer and set up for the print job, using the CommonDialog control. The user then selects the printer and sets the duplex mode, then closes the printer setup dialog and sends the job to the printer. The duplex setting that was selected from the common dialog control is not carried over for the printout, instead the selected printer's default settings are used, ie, I can select the printer from the common dialog control, but not set the printer settings including duplex.
According to MSDN's web site the printer object and the CommonDialog control do not share information. MSDN recommends using the PrintDlg to change the settings for specific print jobs and provides a downloadable PrintDlg.dll. I downloaded this dll and used the sample code. When checking the printer settings prior to sending the job to the printer, the duplex setting is as selected from the printer dialog. But again, when the job is actually printed, the duplex mode is set at the default. Again, I am able to select the printer, but not the settings.
I found the attached code which allows me to change the default settings using API calls and works fine for changing the settings and having my print job print properly. But this does change the default settings. I want to be able to change the settings back to the original default. In MSDN help on DevMode, "to reset the default to the global default DEVMODE, call SetPrinter with the Printer_Info_8 structure." There is no code example on how to do this. How would I return use Printer_Info_8 structure to return the printer to original default settings? Or does anyone have a better method of changing the printer settings (such as duplex) for an individual print job.
Print On Network Printer (default) Not Working
Hello,
I have a local printer installed (that is not the default printer) and a network printer that is the default.
If I send a report to print using datareports, printing is correct, but if I send something to print using the printer.print then nothing is printed.
The job is sent to the local printer instead!
I´ve read that VB is supposed to send whatever to the default printer... why then isn´t it working for the printer.print?
I need to print always to the default printer.
How Do I Get Print Dialog To Not Change Default Printer?
Is it possible to use the Print Dialog to select a printer without the current default printer being changed to whatever is selected?
I would like to use the print dialog to allow a user to select a printer. Then use this printer and the print object to print to this printer. I do not want the current default printer to be changed? It seems to me other programs such as Word and Excel do this is it possible in VB?
Do I have to restore the default printer with something else after using the dialog?
I have seen ways to set the default printer and I think I have read in some places that to get the current printer selection from the dialog the default printer has to be changed, but is there another way to get printer selection and settings without changing the default printer?
Here is my code to show the print dialog and print.
With dlgCommonDialog
.DialogTitle = "Print"
.CancelError = True
.Flags = cdlPDReturnDC + cdlPDNoPageNums
If Err <> MSComDlg.cdlCancel Then
Call Print_DR1
End If
End With
Any help would be greatly appreciated!!!!
How To Set Default Printer In PDF And Print PDF One Page At A Time
How to set default printer in PDF and print PDF one page at a time
The code below will print a PDF file to a tiff converter driver "PEERNET.DRV ePro 5.0" but I am prompted for a filename (a TIFF file) to print to.
I can only do this after setting "PEERNET.DRV ePro 5.0" as the default printer through the printer panel.
What I want is to be able to set the default printer programmatically, print all pdf file pages to individual TIFF pages (with individual names of course).
Lastly, reset the printer back to the original default printer.
(what is not declared here should be considered to be global)
Private Function GetImageFromPdf(strDirName As String, _
astrDestFolderName As String, _
astrFileName As String, _
strFileNameStem As String, _
imageType As String)
Dim fileFullPath As String
Dim AcroExchAVDoc As Object, AcroExchPDDoc As Object, _
AcroExchApp As Object
'Dim fileFullPath As String ', strPath As String
Dim iNumberOfPages As Integer
On Error GoTo HandleError
Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchAVDoc = CreateObject("AcroExch.AVDoc")
Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")
' must restore remed out for debugging multiselect
' when we open the file it will return true/false
fileFullPath = strDirName & "" & astrFileName
'openResult = myPDFPageCount.Open(fileFullPath)
' Open the [strFileName] pdf file
' AcroExchAVDoc.Open strPath + strFileName, ""
AcroExchAVDoc.Open fileFullPath, ""
' Get the PDDoc associated with the open AVDoc
Set AcroExchPDDoc = AcroExchAVDoc.GetPDDoc
'SavePrinter = App.ActivePrinter ' works for MS Wordl for windows
' vbPRPSLegal is a constant for 8 1/2 x 14 in legal size
Printer.PaperSize = vbPRPSLegal
'AcroExch.avdoc.PrintPages 0, pddoc.GetNumPages - 1, 1, False, False
‘AcroExchApp.ActivePrinter = "PEERNET.DRV ePro 5.0" ‘ BBBOOOOOMBS
'Note The first page in a document is page 0 for OLE automation.
' from http://csis.pace.edu/~anderson/AIS/art1.html
For pagenumber = 0 To pageCount - 1
' Print all pages in this document
'AcroExchAVDoc.PrintPages 0, iNumberOfPages, POSTSCRIPT_LEVEL, True, False
AcroExchAVDoc.PrintPages pagenumber, pagenumber, POSTSCRIPT_LEVEL, _
True, False
DoEvents
Next
' Close this file
AcroExchAVDoc.Close True
End Function
Print File To Non Default Printer Without User Intervention
How can I print I file to a specific printer, without user intervention?
My first option was this
Code:
.
.
.
Open fileName For Input As #1
Printer.FontName = "Courier"
Printer.FontSize = 12
l = 0
While Not EOF(1)
Line Input #1, str
Printer.Print str
l = l + 1
If l = 56 And Not EOF(1) Then Printer.NewPage
Wend
Printer.EndDoc
Close (1)
.
.
.
But it prints to the default printer
Code:
.
.
.
Open filepath & "SISIMinvPrt.bat" For Output As #1
Print #1, "NET USE LPT1: /DELETE"
Print #1, "NET USE LPT1: " & invPrinter
Print #1, "Copy " & Chr(34) & Replace(fileNames, ",", Chr(34) & " LPT1" & vbCrLf _
& "NET USE LPT1: \sia2LEXMARKC" & vbCrLf _
& "Copy " & Chr(34)) & Chr(34) & " LPT1"
Close #1
Shell Chr(34) & filepath & "SISIMinvPrt.bat" & Chr(34)
.
.
.
The code above works partially
fileNames contains all files to be printed separated by a comma
The problem is that after printing the first file the rest of the files dont start at the top.
Print Dialog - Problem Resetting Printer To Default
I'm using the API to bring up a print dialog and return info from the dialog (I got the code off AllAPI.net). I then want to set the printer to the selected print dialog printer without changing the default. The code below works fine:
NewPrinterName = UCase$(Left(DevMode.dmDeviceName, InStr(DevMode.dmDeviceName, Chr$(0)) - 1))
If Printer.DeviceName <> NewPrinterName Then
For Each objPrinter In Printers
If UCase$(objPrinter.DeviceName) = NewPrinterName Then
Set Printer = objPrinter
'set printer toolbar name at this point
End If
Next
End If
At this point, the printer.devicename is the same as that just set from the print dialog. However, I also want to run the following lines of code...
On Error Resume Next
'Set printer object properties according to selections made
'by user
Printer.Copies = DevMode.dmCopies
Printer.Duplex = DevMode.dmDuplex
Printer.Orientation = DevMode.dmOrientation
Printer.PaperSize = DevMode.dmPaperSize
Printer.PrintQuality = DevMode.dmPrintQuality
Printer.ColorMode = DevMode.dmColor
Printer.PaperBin = DevMode.dmDefaultSource
...but as soon as I execute the "Printer.copies = ..." statement, the Printer and Printer.DeviceName are reset to the default.
Any ideas why this is happening? I'm still running VB5.
Change Default Printer Before Using Shell Execute To Print Pdf Dicuments From Excel
hi
I have made program that prints pdf documents from excel using shell execute command. Since I have to print documents differently I have to change the printer to which I send the documents during the run time.
So can anyone tell me how to change the default printer in vba excel. shell execute function only prints to the default printer. Therefore I need to change the default printer.
bye
Avoid Printer From Ejecting The Paper After The Last Line Printed? (VB - Printer.print)
how to stop the printer from ejecting the paper after the last line has printed?
assume i'm making an invoice for my small store, and i want to print the items my customer bought downward, so whether it's 1 item, or 5 items, or 100 items, i want the printer stop after the last item has printed ( plus my invoice's footer off course ). i am using VB 6, and 'printer.print' code to print and my printer is EPSON LX-300+. and my database is SQL Server 2000 Developer Edition. is there anyone can help? i really appreciate any help you offer
PS : i've been searching this forum and try all topics related to my issue but nothing's suitable for me...so if there's someone can be more specific, i would really appreciate it
How To Check The Printer On The Network Before Printer.print Method?
Hi,
I am trying to write code to be able to give user option to choose a
printer on the network before they can printer the job.
With printer.print method, VB will not prompt the printer on the
network.
It will only print to the default printer.
Is there a way to be able to choose the printer?
Thanks!
Printer Not Responding To Printer.Print --> Help Newbie
First... I am depressed like hell to get this to work.
Problem: I have an "Eltron 310" ID Card Printer. I am trying to do
Printer.PaintPicture IMG_ID,0,0 (where IMG_ID is a picture)
Printer.EndDoc
The above
--> Works with normal printer
--> Does not work with ID Card Printer. ID Printer doesn't even respond to the command, Printer.PaintPicture, nor does it respond to Printer.Print "some text"
PLEASE HELP. ANY CODE IS GREATLY APPRECIATED.
Thanks
Sreeni
Printer Not Responding To Printer.Print --> Help Newbie
First... I am depressed like hell to get this to work.
Problem: I have an "Eltron 310" ID Card Printer. I am trying to do
Printer.PaintPicture IMG_ID,0,0 (where IMG_ID is a picture)
Printer.EndDoc
The above
--> Works with normal printer
--> Does not work with ID Card Printer. ID Printer doesn't even respond to the command, Printer.PaintPicture, nor does it respond to Printer.Print "some text"
PLEASE HELP. ANY CODE IS GREATLY APPRECIATED.
Thanks
Sreeni
? Printer Should Print Your Current Printer - Correct?
I am right in assuming that if I run a standard .exe program and I pause it...then type in the Immediate window the following:
Code:
? Printer
then it should come up with the default printer name - correct? Please let me know if I'm wrong.
Thanks,
Stephen
"Printer.print & Printer.currentx/y"-question
Hello,
Im kinda a newby (not really), but i need some answers to newby questions...
I got a nice program wich outputs data on my form...
NOW, i want to print the information with my printer...
and i've read some stuff about it... and found the "Printer.print"-method the best solution...
SO, now I got some questions about it...
--> when i say "printer.currectx = 250", then where will the printer print my stuff??
- at 250 mm from the leftmargin
- at 250 mm form the paper
- at 250 pixels from the leftmargin
- at 250 pixels from the paper
- at somewhere else
What i'dd like is it be printed at 25 mm from the paper...
tnx anyway....
How Can Print To Local Printer Using "Printer.port"
Hi all, I have a local printer which is connected to one computer. I use the code printer.port which works well and prints to printer. But when i try to print from another computer which is a lan it gives the error "Bad file number".
How can i do this
Set Default Paper Size For Default Printer ...
So, hope that someone could help me..hix..
If i cant do this i will loose my job, my boss say so. I have to print a webpage with the size of paper is A5 baut the default always is Letter, hix, I could change it by hand but the users may not. So i want to set the default paper size of default printer to A5.
Thanks a lot.
Changed Default Printer But Job Goes To Old Default...
I have a print command with the following code:
Code:
Private Sub cmdPrint_Click()
Dim tmpPrinter As Printer
Dim DefaultPrinter As Printer
Set DefaultPrinter = Printer ' Save the default printer
For Each tmpPrinter In Printers
If tmpPrinter.DeviceName = cmbPrinters.Text Then
Set Printer = tmpPrinter
Exit For
End If
Next tmpPrinter
CrystalReport1.ReportFileName = FileIn.Path & "" & FileIn.FileName
CrystalReport1.Destination = crptToPrinter
CrystalReport1.PrintReport
MsgBox "Your report was printed"
Set Printer = DefaultPrinter ' Change back to default printer
End Sub
where the combo box is populated by this code:
Code:
i = 0
For Each InstalledPrinters In Printers
cmbPrinters.AddItem InstalledPrinters.DeviceName
i = i + 1
Next InstalledPrinters
cmbPrinters.ListIndex = 0
I select a printer (not the default printer, but a different one) from the combo list, then click on Print and the job is still going to the original default printer. Stepping through the code, I can see how Printer changes (to the printer I selected) during the execution, but the job keeps going to the old default printer. Also the last line of code in the cmdPrint_Click sub gives me a "Run-time error '13': Type mismatch" error.
What am I missing? Can anyone help please?
Thanks,
poli
Default Printer
I have a network computer with a printer attached to lpt1 that I use for printing. The problem is, since the computer uses a dynamic ip I have to reconnect to the printer every time the computer restarts, it uses one of three ip addresses ( since there are three computers on the network). I have tried connecting to the printer by the computer's name, but this doesn't work. Can a small app be written to check and see if there is a printer attached to a network computer and if it's there set that printer as the default? I think I need a winsock control to "ping" the computer and if there's a response to set the printer to the default. Can this work, and if so, how can it be done/where can i learn how?
Thanks,
redrum
Default Printer
I have two printers that have been setup in my computer. One is local and the other is in the network. My program needs to print in those two printers. How can I change the default printer of my computer? Im using vb6 in Windows 98 OS.
Help! How To Set Default Printer Using VB?
I have 5 printers connected to my machine, and I set Printer(2) as default in system's Control Panel, now I want to print the data report to different printer, so I try to change printer using following VB code:
private sub command1_click()
Set rsPrinter = New Recordset
strSql = "select * from PPRINTERSITE where SITEID = '81';"
rsPrinter.Open strSql, g_dbConn, adOpenKeyset, adLockOptimistic
If Not rsPrinter.EOF Then
For Each prt In Printers
If prt.DeviceName = rsPrinter("PRINTERNAME") Then
MsgBox "Printer is " & prt.DeviceName
Set Printer = prt
Exit For
End If
Next
End If
dataReport1.PrintReport
end sub
though the message from MsgBox told me the Printer already changed to other printer ( such as Printer(0) ), but the dataReport1 still be printed in Printer(2), Can someone help me?
Thanks
Yinghong
Default Printer
Hi all, is there a way to use vb code to set the default printer to print a crystal report w/i vb? Currently there is no way to change the default printer from the crystal report (crviewer)....please help..thanks!
Get Default Printer
Hi,
I want to find an API functions that tells me the name of default printer installed on my computer. 'Printer' object from VB is not enought for what I need.
Thanks
Lucian
Add Default Printer
I need to know how to add printers (including the default) to a Windows 2000 workstation using Visual Basic code. I want to automate the process instead of manually adding. Does anyone have any code that I could use? Thanks!
Default Printer
i have a small program that basically copies information from a flex grid into excel. however, i've found that the page setup properties are not active if there aren't any printers installed.
my question is what's the best way to check for installed printers? i tried an if statement: if printer.devicename = "" then don't do the page setup properties, but i still get the error 'Problem getting printer information from the system. Make sure the printer is set up correctly.'
any thoughts?
thanks,
jb
Which Is The Default Printer
I'm using the code below to change printer queues from one to the other. I need to know if the printer is the "Default Printer" before I change it. Here is the code I'm using: Thanks for the Help.
'******************************************************
'* File: ChangePrinter
'* Created: May 2003
'* Version: 1.1c
'*
'* Main Function: Changes Printer Paths
'* Usage: ChangePrinter.VBS \ServerNameOldPrinter \ServerNameNewPrinter
'*'****************************************************
'Get the command line arguments
if (Wscript.arguments.count > 2) or (Wscript.arguments.count < 2) then
wscript.echo "You put the wrong number of arguments you need to put 2. Put the old printer path first, followed by the new printer path. ex. changeprinter \hqptrz010500 \hqptrz010501"
WScript.Quit
end if
OldPrinterPath = Wscript.arguments.item(0)
NewPrinterPath = Wscript.arguments.item(1)
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oPrinters = WshNetwork.EnumPrinterConnections
For i = 0 to oPrinters.Count - 1 Step 2
If lcase(OldPrinterPath) = lcase(oPrinters.Item(i+1)) then
' Add the New Printer
WshNetwork.AddWindowsPrinterConnection NewPrinterPath
' Make the New Printer the Default Printer.
WshNetwork.SetDefaultPrinter NewPrinterPath
' Remove the Old Printer
WshNetwork.RemovePrinterConnection OldPrinterPath,true,true
End if
Next
Set WshNetwork = Nothing
Set oPrinters = Nothing
WScript.Quit
Set Default Printer OCX
Can't seem to put it into the code library but gonna put it here instead.
An ActiveX Combo To Find All Installed Printers and Specify The Default Printer.
Enjoy
Default Printer
Hi, I wish to get the device name of the default printer but VB's API does not do it. I did a search on the forum and found one thread, that thread has a link to another site about retrieving the default printer's device name but the site is no longer avaiable. Is there anyone that can help?
Default Printer
can anybody help me about how to use the windows default printer to print something? if there is a tutorial i think that will be best for me.
Default Printer
Well, seeing as this forum now includes "reporting" is suppose that this thread belongs here. If not, please feel free to move it.
How do I set the current printer to the default printer, having changed it to a not default printer?
P.S. I've searched a few returned entries in Google and none of them have the answer that I'm after.
Can't Set Default Printer
This is crazy. There are 2,000 topics on the default printer, but I still can't solve my problem. My program prints fine but I can't change the default printer.
I can't execute a simple command. Is there some component or reference I need in my program.
This gives me an "Object Required" error
TempString = "Canon Bubble-Jet BJC-265SP"
Set Printer = TempString
This is the code I want to use.
VB Code:
Dim strCurrentPrinter As String 'get current printer name and store itstrCurrentPrinter = Printer.DeviceName 'To set your printer as default printerSet Printer = "Your Printer Name" 'Do your codings to print Set Printer = strCurrentPrinter 'to set back the earlier printer as default
Default Printer
How to get the default printer in my machine and also check the status and print a pdf file by vb?
Set Default Printer
I have searched for some help on this, but it is very vague and/or complex.
I need to retrieve the name of the default printer, change it to Win2PDF, do some printing and then change the printer back to the old default.
The system default printer is found at hkey_current_userssoftwaremicrosoftwindows ntcurrentversionwindows.
How can I read that name, change to Win2PDF and then change back again?
PS.- I am currently using a program called sdp.exe (Set Default Printer) and it is excellent, but if the user changes their printer, my program won't work properly.
VB Default Printer
It is my understanding that the VB printer is the default system printer and the object Printer will print to the system default printer. I use the following code to change the orientation to landscape
CommonDialog1.Flags = &H40
CommonDialog1.PrinterDefault = True
CommonDialog1.ShowPrinter
On completion of the CommonDialog1.ShowPrinter the orientation in the Printer object is still protrait.
What am I missing here??????
Default Printer
what is the simplest way to set a default printer with code?
|