There are 3 printers showing when I print from Excel, Outlook etc.
When I call PrintDialog1.ShowDialog() it is only showing the default printer.
How can I show all available printers?
Thank you
This should get you a list of installed printers, if it they don't show up with this code, it may be that you need to update drivers?
Dim controller As New ServiceController("Spooler")
If controller.Status = ServiceControllerStatus.Running Then
'http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/fe615570-ce3e-419b-86fc-7f98aed71c8f
For Each currentPrinter As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters
'now add the currentPrinter to a list ...
Next
End If
Related
I want to call the Windows Print Pictures dialog using VB.net. the one Windows comes up with when you go to print a picture, the one that lets you print full page, 8X10, 4X6, 5X7, contact sheet, etc.
I've tried using printdocument and printdialog but those only give you the standard print dialog window for documents.
I've searched Google and all the results were completely unrelated to the Print Pictures dialog and therefore completely useless.
I've seen the same question for C+ here
Print image using windows print image dialog
using CLSID_PrintPhotosDropTarget COM object.
but this doesn't really help me since I'm using VB.net (Visual Studio 2008 to be precise) but I'm including it here as it has a screenshot of the dialog I am trying to call.
any help would be appreciated.
Okay, just this once, I will translate for you but you need to find an on line converter that you like. Many examples are available in C#. Also please take the tour to learn how to ask a proper question.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'The C# code
'String fileName = #"C:\Development\myImage.tif";//pass in Or whatever you need
'var p = New Process();
'p.StartInfo.FileName = fileName;
'p.StartInfo.Verb = "Print";
'p.Start();
Dim fileName = "C:\Users\xxxx\Desktop\Graphics\Baby owl.jpg"
Dim p = New Process
p.StartInfo.FileName = fileName
p.StartInfo.Verb = "Print"
p.Start()
End Sub
I use the following code
Dim PrintR_ As Printing.PrinterSettings = ReportViewer1.PrinterSettings
PrintR_.PrinterName = "Microsoft XPS Document Writer"
ReportViewer1.PrintDialog(PrintR_)
However, when executed, the following form appears
All I want is not to see this screen and to print directly based on the printer's specific name
Thanks for everyone who helps.
I want to be able to have my app check if Adobe Reader is installed.
If it is, I want my program to use it to display the PDF, if not I want to use my free (limited) reader control to display the PDF.
Any suggestions
Edit:
my question seems to be little to broad
So basicly i'm trying to do the following
Try
Dim AcroDisplay As New AxAcroPDFLib.AxAcroPDF
AcroDisplay.Left = 50
AcroDisplay.Top = 50
AcroDisplay.Width = 200
AcroDisplay.Height = 500
me.Controls.Add(AcroDisplay)
MsgBox("Acro Added")
Catch ex As Exception
MsgBox("Acro Not installed")
''Load Alternate PDF viewer (Spire.pdf Free)
End Try
However when Acrobat Isn't installed instead of going to the catch statement it just shows an error "Could not load assembly" and then exits the sub
What i want is that if acrobat control isn't installed, that it wont display and error and instead just load the alternate pdf viewer
is there a way to check for AxAcroPDFLib.AxAcroPDF before attempting to load?
Hopefully this makes things clearer
Edit 2:
After Searching and screwing around i found 2 possible ways i might be able to do this
however both i can't find how to do it in VB.net
First
Look for AxAcroPDFLib.AxAcroPDF in available namespaces
found C# example but i don't know how to change it to Vb.net
C# - How to check if namespace, class or method exists in C#??
Second
Add Unhandled Exception Handler
also found a few examples but none seem to work
Any Chance anyone could direct me to a working example for either (or both) of these options
Manged to fin a working solution, doesn't work how i was originally thinking but it doe work just fine
i used the following code
Dim AdobeSoftwares As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("ADOBE")
If AdobeSoftwares Is Nothing Then
'MessageBox.Show("No Adobe Software")
Dim PdfDisplay As New PdfiumViewer.PdfViewer
PDFControl = "Pdfium"
Else
If Not Array.IndexOf(AdobeSoftwares.GetSubKeyNames, "Acrobat Reader") = -1 Then
'MessageBox.Show("Adobe Reader Installed")
Dim PdfDisplay As New AxAcroPDFLib.AxAcroPDF
PDFControl = "Acrobat"
Else
'MessageBox.Show("Adobe Reader Not Installed")
Dim PdfDisplay As New PdfiumViewer.PdfViewer
PDFControl = "Pdfium"
End If
End If
Then in my display code i just look to see what "PDFControl" is in use and run the relevant code to display in that display
So now if adobe reader is installed, I'll be using its control, and if it isn't I'll be using the free (but less featured) control to display PDF files
So hopefully if anyone else is looking at doing similar to me then they can
I'm troubleshooting an issue with a VB.NET app that I inherited.
The following lines execute print operation:
Me.rptShippingLabel1.PrintOptions.PrinterName = "LabelPrinter"
Me.rptShippingLabel1.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape
Me.rptShippingLabel1.PrintToPrinter(Me.txtLabelQty.Text, False, 1, 1)
There is a Zebra ZDesign TLP2844 connected to workstations via direct USB and named LabelPrinter. However, despite target printer being specified in the code, that Zebra must be set as default printer in Windows, otherwise the job would go to any other printer set as default.
What's even more frustrating is that on some computers, with exactly the same configuration jobs go to correct printer but I can't identify controllable pattern.
Any suggestions why might that be?
Reports in question are disassociated from printer in Design>Page Settings.
Look into your report. In page settings see if report is optimized for display. If yes, uncheck it. If report is optimized for displaying only, PrinterOptions enumeration is being discarded. You could still assign to Printer name property in older framework but not anymore.
Try the following code
Dim rptShippingLabel1 As New CrystalReport1
Dim PrinterSettings1 As New Printing.PrinterSettings
Dim PageSettings1 As New Printing.PageSettings
'Replace it with your printer name
PrinterSettings1.PrinterName = "Microsoft XPS Document Writer"
rptShippingLabel1.PrintToPrinter(PrinterSettings1, PageSettings1, False)
to get the printer name, don't read it from rptShippingLabel1.PrintOptions.PrinterName it will show blank. Try reading from PrinterSettings1.PrinterName.
This is tested with Crystal Reports runtime 13.0.9
I have a OpenFileDialog and its MultiSelect property is ON. My question is how can I limit the number of items to be selected, for example 5 items only?
Thanks
You can use the FileOk event to check the file(s) selected by the user when he clicks the OK button. If you are not happy then display a message and set the CancelEventArgs.Cancel property to True to prevent the dialog from closing. Like this:
Dim dlg As New OpenFileDialog()
dlg.Multiselect = True
AddHandler dlg.FileOk, Sub(s, ce)
If dlg.FileNames.Length > 5 Then
MessageBox.Show("Please select no more than 5 files")
ce.Cancel = True
End If
End Sub
If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then
'' etc...
End If
You cannot. But you have alternatives:
1.- A good alternative could be to put all file names in a text file, and then accept that text file as your program's input.
2.- You should allow user to pick the directory. Then you list all the files and let them select as many files, there will not be any problem.
3.- You may have to use a FolderBrowserDialog instead and then use IO.Directory.GetFiles, which works properly.
There is no built-in feature for that in OpenFileDialog as far as I can see. Possible solution is to check FileNames returned from the dialog. If it count more than 5, for example, alert user and stop without operating the files.