Print Common Dialog
Most of the code I have seen that shows the print common dialog via API then sets the Printer object to the DevMode type properties, seems to put a 32 character limit on the dmDeviceName. For example, on my machine I have a network printer installed named \SHENANDOAHEPSON Stylus COLOR 900 but the dmDeviceName returns it as \SHENANDOAHEPSON Stylus COLOR plus a vbNullChar. Is there anyway to get around this or should I just compare the first 32 characters of Printer.DeviceName with dmDeviceName and hope that none of my clients have two different printers that have the first 32 characters the same?
Thanks
BestCoder
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Print Images That Fit To The Page Size Specified In Print Common Dialog?
i need some help in printing the whole image tat fit onto the paper size i specified in Print Common Dialog. I hav a PictureBox array & each PictureBox contains a smaller Picturebox inside. For example : Picture1(index) has a smaller Picture2(index) inside. There are vertical & horizontal scrollbars next to each Picture1(index).
i already hav the basic Print Common Dialog code below. Here's the problem -> I can print out the pictures displayed inside Picture2(index) but the printout will turn out truncated or just part of the whole picture when im printing to a 4R photo size for example and the image displayed in Picture2(index) is larger then the bounding Picture1(index) & i need to use the scrollbars to scroll and view the other portions of the image.
So how to modify the code below to print out the whole image tat fit nicely to the paper size i specified. Thanxs.
'---------------------------------------------------------------------
'CODE
'---------------------------------------------------------------------
CommonDialog1.CancelError = True
On Error Resume Next
CommonDialog1.Action = 5 ' Start the Print Common Dialog
If (Err.Number = cdlCancel) Then Exit Sub
'when Cancel is pressed, exit subroutine
'Code to print the array here
For Pics = Picture2.LBound To Picture2.UBound
If Picture2(Pics).Picture > 0 Then ' If the PictureBox is not empty
Printer.PaintPicture Picture2(Pics).Picture, 0, 0
Printer.EndDoc
End If
Next
'---------------------------------------------------------------------
Print Dialog (common Dialog) Frustration
Hi,
I've read through quite a number of help topics on different forums trying to find an easy solution:
I'd like to achieve the following:
1) show a print setup dialog
2) When user wants to print, the printer object (default printer) would reflect all the changes that the user made in step 1 (that is, the choice of printer, page orientation, papersize etc.)
For step 1, I know that code
commondialog1.flags = cdlPDPrintSetup
commondialog1.showprinter
shows the print setup dialog, but how can you easily make use of the user selections? (through experiment I know that setting printer.trackdefault = true makes the printer object reflect at least on the choice of the printer, but not e.g. paper size, at least not consistently).
Thanks for any help,
Efunlake
Common Dialog Print
Hey Guys,
I have searched, but couldn't find an answer.
I have made a program in VB that puts some info on a Excel sheet. If I press 'Print sheet' I can print this sheet on the default printer, but I want to be able to let the user pick a printer and print with that selected printer (only if the user wants to print on another printer than the default printer).
When I show the common dialog for the printer, I don't know how to link the 'Print' button on the common dialog to a certain command to print the active Excel sheet!
Can you help me with this?
Kind regards,
Arjan
Common Dialog Print
I'm using MS Common Dialog for the printer aspect. After I print once it remembers what printer I used and continues to print to it without showing me the dialog box. here's my code.
Code:
dlg.CancelError = True
On Error Resume Next
dlg.ShowPrinter
If Err = 32755 Then
Exit Sub
End If
Printer.Orientation = 1
newp.PrintForm
It continues to print to the same printer even if I close the program and restart it. Thanks!
Print Common Dialog
Hey guys, I'm just starting to learn how to use the common dialog print box. First, I open it with
Code:
Dialog1.ShowPrinter
but I don't understand how to tell if the user hits the print or cancel button on the dialog box. This is probably something simple, but I can't find it in the object browser or by searching. Thanks in advance!
Common Print Dialog
i have an option to print something
when you click on the print button the print dialog comes up, allowing you to choose the printer, what pages to print and how many copies etc.
if you click ok, it goes ahead and prints, the problem is, if you click cancel it prints anway
how do i take the response from the print dialog? so that i can print if the user clicks ok, and nothing happens if they click cancel
Common Print Dialog
Please help.
I am accessing the printer common dialog through api calls as i do not have the ocx installed and cannot install it (due to corporate red tape). however all is working fine, dialog box appears, selections are, made but when I return to the calling procedure and set the new printer name, that is accepted, when it then sets the number of copies the printer device name is reset to the windows default
Public Type DEVMODE_TYPE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Public Function ShowPrinter(frmOwner As Form, Optional PrintFlags As Long) As DEVMODE_TYPE
newprintername = ShowPrinter(frm)
For Each objprinter In Printers
If UCase$(objprinter.DeviceName) = Left(newprintername.dmDeviceName, InStr(1, newprintername.dmDeviceName, Chr(0)) - 1) Then
Set Printer = objprinter 'at this point the printer is set
correctly
Printer.Copies = newprintername.dmCopies'when this line
executes the
printer is changed back to
the windows default
Printer.Duplex = newprintername.dmDuplex
Printer.Orientation = newprintername.dmOrientation
Printer.PaperSize = newprintername.dmPaperSize
Printer.PrintQuality = newprintername.dmPrintQuality
Printer.ColorMode = newprintername.dmColor
Printer.PaperBin = newprintername.dmDefaultSource
End If
Next
Common Dialog: Print?
VB Code:
Private Sub cmdprint_Click()cdbprint.DialogTitle = "Select A Printer"cdbprint.ShowPrinterEnd Sub
i know i'm missing something but i don't know what. can someone finish that for me, i know its easy i just dunno what i'm doing.
Print Common Dialog?
Ok i asked every common dialog thingy, this is the last to go to implement in to a basic text program....
I know the first part:
VB Code:
Private Sub Print_Click()CommonDialog1.ShowPrinterEnd Sub
Now how do i get it to print the RichTextBox1.Text?
~$uper-$tar
Common Dialog For Print
I've managed to get the print dialog to display however i'm not sure what the code is to send the data to the actual printer. Can anyone help?
This is what I have so far:
Private Sub cmdPrint_Click()
Dim BeginPage, EndPage, NumCopies, Orientation, i
' Set Cancel to True.
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
' Display the Print dialog box.
CommonDialog1.ShowPrinter
' Get user-selected values from the dialog box.
BeginPage = CommonDialog1.FromPage
EndPage = CommonDialog1.ToPage
NumCopies = CommonDialog1.Copies
Orientation = CommonDialog1.Orientation
For i = 1 To NumCopies
' Put code here to send data to your printer.
Next
Exit Sub
ErrHandler:
' User pressed Cancel button.
Exit Sub
End Sub
Common Dialog (Print)
<vbcode>
I am trying to fix a program that I did not write. I am not too familiar with Common Dialog but here is the code:
Private Sub cmdPrint_Click()
On Error Resume Next
Dim BeginPage, EndPage, NumCopies, Orientation, i
Dim ActiveForm, dlgCommonDialog
With dlgCommonDialog
.DialogTitle = "Print"
.CancelError = True
.Flags = cdlPDReturnDC + cdlPDNoPageNums
If ActiveForm.rtfText.SelLength = 0 Then
.Flags = .Flags + cdlPDAllPages
Else
.Flags = .Flags + cdlPDSelection
End If
.ShowPrinter
If Err <> MSComDlg.cdlCancel Then
ActiveForm.rtfText.SelPrint .hDC
End If
End With
'Get user-selected values from the dialog box.
BeginPage = dlgCommonDialog.FromPage
EndPage = dlgCommonDialog.ToPage
NumCopies = dlgCommonDialog.Copies
Orientation = dlgCommonDialog.Orientation
' For i = 1 To NumCopies
'Put code here to send data to your printer.
Printer.Orientation = 1 'Portrait
dlgCommonDialog.Orientation = cdlPortrait
End Sub
The Common Dialog is included on another form, but print dialog does not "pop-up".
any advice?
</vbcode>
Print Dialog Box (Common Dialog Box)
Hi,
Does anyone know how to make the pages section of a print dialog box enabled. I'm referring to the print range frame. I know you can set the
flags property of the common dialog control, but setting this to &H2 which is what should make it become enabled does not do anything. Am I
overlooking something?
thanks
MS Common Dialog Print Command
If I try to use the .showprint command more than once in a program, it wont work. I have to restart my program for me to be able to use it again. Any clues??
Code:
dlg.CancelError = True
On Error Resume Next
Printer.PrintQuality = 4
dlg.ShowPrinter
If Err = 32755 Then
Exit Sub
End If
Printer.Orientation = 1
newp.PrintForm
Common Dialog Print Problem
Hey folks,
I am having trouble showing out the print common dialog immediately after I show out a open dialog box.
The problem is whenever I use the common dialog object to show an Open Dialog box and after that I use the same common dialog object to show the Printer Dialog box, it refuses to pop up. Instead of doing that. It skips the Show Printer line and executes my printing codes. Weird ! Help ?
Thanks in advance...
Common Print Dialog Box Properties
I am using VB6 and Crystal Reports 8.5 with Windows 2000 operating system and decided to use the VB print dialog box.
When called, using “CommonDialog1.ShowPrinter”, the VB print box displays a three tabbed section print common dialog box: General, Layout, and Paper/Quality. Using the code between the “With CommonDialog1” and “end with” below, the following code enables the features that I want on the general section tab of the VB print dialog box:
With CommonDialog1
.Flags = cdlPDPageNums
.Min = 1
.Max = 999
.FromPage = 1
.ToPage = 999
End With
Question: What are the property variables for the other two tabbed sections of the print common dialog box and what system variables has to be updated (with the user settings) from the common dialog box?
For example, this statement gets a value from the common dialog print box:
orientation = commondialog.orientation
What does orientation (1 for portrait, 2 for landscape) update in VB6?
I appreciate anyone's help. Thanks.
Common Dialog Print Control, Etc.
I teach VB in High School and look like a fool today when I could not get form to print using Common Dialog Control. Have a rather large form which I need to print in landscape orientation. Current code:
Private Sub mnuPrintForm....
CommonDialog1.ShowPrinter
End Sub
The textbook offers no other info.
The only way I can print the form is to eliminate the commondialog control and just type in the PrintForm command, but still does not print landscape.
Thanks for any help.
Common Dialog Print Function
I've formated and writen a PCL print file from inside my program to the harddrive. Now i want to send it to a PCL printer on the network. (its done over windows network) \servernameprinter001 etc.
Can I in someway retrive the path to the printer using the Common dialog printer object? It would be so sweet if the user could select the Printer from the standard windows printer selector.
/Anders
How To Set Common (Print) Dialog Language?
How do you change the language displayed for the common dialog control (Print, Open, etc)? Is this even possible? I am amazed at how difficult its been to find any information on this!
My application is written in VB 6.0 and runs on Windows NT 4.0 SP5. The language the application runs in (via resource file) is based on the Locale chosen by the user. However, changing the Locale seems to have no impact on the text displayed on the Common Dialog control.
I am using the Microsoft Common Dialog Control 6.0 (SP3) - comdlg32.ocx
Any info would be greatly appreciated - Thanks!
Print Common Dialog Control Please Help
I need to figure out how to return the name of the printer
selected in the CommonDialog control for printers
cdSelectPrinter.ShowPrint
I don't even know if this is possible or not.
I know how to print and get a list of installed printers(thanks to Johnny101)
I just would like to know if the printer name selected in the CommonDialog Control can be returned.
If not can you force the CommonDialog Control to accept a printer name instead of listing all installed printers?
Any help is greatly appreciated!!!
Common Dialog Print Setup && Memory
HI, I have a program that is using the commondialog option of print setup but when my program is running and I select this option on a particular laptop an error message appears "Not enough memory for this operation". My program works on numerous computers and laptops and this particular laptop has 128ram and enough disc space. Has anyone any ideas?!
Thanks
Hazey Daze
Print Setup Common Dialog Question
Previously, we were keeping the PrinterDefault property of the CommonDialog control as True, which would set the windows default printer to the printer selected when using the Print Setup dialog.
However, in most applications, the default printer does not get changed when you use the Print Setup option.
The problem is, without the PrinterDefault property, the Printer object is still the default printer, and the printer the user selects in the Print Setup dialog is not retained, i.e. if you open it again, the printer is reset to the default printer.
I can't seem to find any help on existing forum sites, so does anyone have a clue how to be able to do the following?
1. Allow the user to select a printer using the Print Setup dialog (done).
2. Do not set the windows default printer to the selected printer (done).
*3. If they open up the Print Setup dialog, show the printer last selected.
*4. When they decide to hit the Print button, print to the printer last selected.
There must be a property or flag or something out there (or maybe even an api call?) that I am not seeing.
Thanks in advance,
-Keith
Common Dialog/PrintDialog API Print Range
All,
I have exhaustively searched this website as well as other to find how to activate the Current Page or the Pages radio options on either the commondialog control or the PrintDialog API. If anyone could point me in the right direction that would be helpful.
I have been setting the .Flags to cdlPDPageNums, in fact, I have tried all available flags in some combination. Maybe there is a trick to an And/or clause in the setting of the flag that I am just not getting correct.
Thanks in advance
How To Print Form Using Common Dialog Control ?
I am using a MDI parent form with a menu command to print form.
1. How do I use a Common Dialog Control to let users select options before print?
2. If the user opens more than one form and clicks print, how could it print the active one?
Any sample code will be very helpful. Thanks.
Common Dialog Box Question (save And Print)
heres a three parter...
1) is there a way to clear out the history for file name when using the save common dialog box control?
2) how do i print the contents of a rich text box when using print common dialog box...
the code i have Code:RichTextBox1.SelPrint Printer.hDC prints whatever is selected in the textbox and if nothing is selected, it prints out the whole thing...
but when the printer dialog box appears and you have something selected and you want to print the whole thing by picking all in 'page range' it still prints out what was selected.
3) is there a way to set the margins when printing using the common dialog box control?
when i print, the margins are very small
anyone know how to deal with these?
thanks!
primal
Print Existing Excel File Using Common Dialog
What I need is to click on my command button and open a common dialog box for printing. Then print a specific excel file I created. What code do I add to print my excel file.
Private Sub cmdPrint_Click()
Dim printDlg As PrinterDlg
Set printDlg = New PrinterDlg
printDlg.PrinterName = Printer.DeviceName
printDlg.DriverName = Printer.DriverName
printDlg.Port = Printer.Port
printDlg.PaperBin = Printer.PaperBin
Printer.TrackDefault = False
printDlg.CancelError = True
Dim NewPrinterName As String
Dim objPrinter As Printer
Dim strsetting As String
NewPrinterName = UCase$(printDlg.PrinterName)
On Error GoTo ErrorHandler
printDlg.ShowPrinter Me.hWnd
If Printer.DeviceName <> NewPrinterName Then
For Each objPrinter In Printers
If UCase$(objPrinter.DeviceName) = NewPrinterName Then
Set Printer = objPrinter
End If
Next
End If
Printer.Copies = printDlg.Copies
Printer.Orientation = printDlg.Orientation
Printer.ColorMode = printDlg.ColorMode
Printer.Duplex = printDlg.Duplex
Printer.PaperBin = printDlg.PaperBin
Printer.PaperSize = printDlg.PaperSize
Printer.PrintQuality = printDlg.PrintQuality
With Printer
Debug.Print .DeviceName
If .Orientation = 1 Then
strsetting = "Portrait. "
Else
strsetting = "Landscape. "
End If
Debug.Print "Copies = " & .Copies, "Orientation = " & _
strsetting
If .ColorMode = 1 Then
strsetting = "Black and White. "
Else
strsetting = "Color. "
End If
Debug.Print "ColorMode = " & strsetting
If .Duplex = 1 Then
strsetting = "None. "
ElseIf .Duplex = 2 Then
strsetting = "Horizontal/Long Edge. "
ElseIf .Duplex = 3 Then
strsetting = "Vertical/Short Edge. "
Else
strsetting = "Unknown. "
End If
End With
ErrorHandler:
If Err.Number = 32755 Then
Exit Sub
End If
Print A Rich Text File Without Common Dialog?
i was wondering if there was a way to print a .rtf (rich text file) without using the common dialog control, so that no dialog boxes come up.
i found some code that would print a .txt file, but it can't do rich text.
any ideas?
Printer Defauls Not Being Changed By Common Dialog Print Control
I am having a problem with printing. If I change the default settings of the printer, the changes I make in the common dialog print control are not being updated so my print job is sent with my new printing preferences. I have attached my code below. Any suggestions?
With cmd
.DialogTitle = "Print"
.CancelError = True
.Flags = cdlPDReturnDC + cdlPDNoPageNums
If ActiveForm.rtfText.SelLength = 0 Then
.Flags = .Flags + cdlPDAllPages
Else
.Flags = .Flags + cdlPDSelection
End If
.ShowPrinter
End With
Printer.Font = "courier new"
Printer.FontSize = 10
Printer.Height = (1440 * 11)
Printer.CurrentX = 5300
Printer.CurrentY = 600
Printer.FontBold = True
Printer.Print Filename
Common Dialog Print Control In VB6 Not Updating Defaults In Printer Driver
I want the user to be able to pick double sided printing and the choice to be able to staple the paper by selecting it in the vb runtime common dialog print control. All of the changes that are made at runtime are not being sent to the printer. Whether you pick to staple or not to staple the page after it prints works from wordpad and notepad but not from my applications. How can you make sure that all selections made in the dialog box is passed to the printer. VB does not support all of the options in the printer object that is in our options dialog of the Common Dialog Control. If anyone knows a way around using the common dialog and actually accessing the core dialog box for the printer, that would be an acceptable method for me also.
With cmd
.PrinterDefault = true
.DialogTitle = "Print"
.CancelError = True
.Flags = cdlPDReturnDC + cdlPDNoPageNums
If ActiveForm.rtfText.SelLength = 0 Then
.Flags = .Flags + cdlPDAllPages
Else
.Flags = .Flags + cdlPDSelection
End If
.ShowPrinter
End With
Printer.Font = "courier new"
Printer.FontSize = 10
Printer.Height = (1440 * 11)
Printer.CurrentX = 5300
Printer.CurrentY = 600
Printer.FontBold = True
Printer.Print Filename
Common Dialog Contol - Font Dialog - *unresolved*
i have a common dialog control.. .names cdFont on my form... and a rich text box... named rtfMain
now... i have a problem and a question
---
Problem
---
when i call cdFont.ShowFont... (default settings)... i get a strange result
first i get a dialog that says "There Are No Fonts Installed. Open the fonts folder from the control panel to install fonts."
there are fonts, lots of them
then... i click ok... then i get error 24574 - no fonts exsist
anyone care to explain why this is happening?
---
Question
---
To change the font name on the rtfMain... its just a matter of rtfMain.Font = cdFont.Fontname isnt it?
thx for your help (if you do decide to help that is )
Browse Dialog For Folders Without Using Common Dialog Control
Is there any way in excel vb script to display an open folder fialog box which returns only folder paths not files. I can get it to work for files using:
Application.GetOpenFilename
However, there doesn't seem to be a command for browsing for a folder. I don't want to use the common dialog control due to current platforms.
Any ideas?
Color Dialog (common Dialog) Problem
I use the commondialog.showColor property to get a value of a color. The problem is that the color is returned in the following format 1254865213 .A very huge number. What I want is to get the #CCCCCC format of the value of a color.How can I do that?
I would appreciate an answer.
Thank you
Common Dialog Control-color Dialog
Hi all,
I am using Microsoft common dialog control 6.0 for color dialog. When I show the color dialog using .showcolor property it is coming in the top left corner of my form. Can I position that color window where ever I want in my form. I am unable to position the window.
Any idea?
-thanks in advance
Santhakumar B
Printer Dialog Of Common Dialog Control
I have one query related to common dialog control for printer. printer dialog provids one facility called "scaling" with the help of that you can scale ur printing object 0-1000%. its working with windows 95 and 98 but not with NT. Why???
Cant Enable Print From And To Textboxes In Print Dialog Box
On Error GoTo GetOut:
CommonDialog1.CancelError = True
CommonDialog1.Flags = cdlPDPageNums
CommonDialog1.ShowPrinter
CommonDialog1.FromPage = 1
CommonDialog1.ToPage = 2
CommonDialog1.PrinterDefault = True
Printer.Print Text1
Printer.EndDoc
Exit Sub
GetOut:
Exit Sub
Common Dialog Box Not So Common?
Hi,
I've had this problem before and i forgot how i resolved it, how do i get fonts to show up on the list when i use the Common Dialog Box to display the font dialog? It get an error saying that i don't have any fonts installed. Any help would be appreciated.
Thanks
-George
Help With Common Dialog
Hey all I am using Visual Basic 6 making a comparision data program but i have tables stored all over the network. I used the Common Dialog Open box, but when i use txttable.text = commondialog1.filename it only returns the filename not the full path so it bottoms out, any suggestions?
Thanks for the help
SkyX
Common Dialog Ocx And Dll
Good Day,
I am currently using Inno Setup.
One of the file I have to include is comdlg32
There is no problem including comdlg32.ocx, but if i try to include comdlg.dllm the compile program will say that it can't include this dll
Will the common dialogs will work on user's machine only with the ocx ?
Thanks
Common Dialog Box
hello, i open an excel file with he common dialog box, this works fine. but if i click on open a file and do not chose a file and exit the common dialog box then it throws an error. is there anyway to stop this.
this is my code
'open the common dialog box
cdlFileBox.ShowOpen
cdlFileBox.Filter = "excel (*.xls)|*.xls"
'Open an Excel workbook
Set MyXLApp = New Excel.Application
Set MyXLWorkBook = MyXLApp.Workbooks.Open(FileName:=cdlFileBox.FileName) '"H:sarahWeeklySpent.xls
thanks
Common Dialog
hi, i am a beginner in vba....so, is anybody know how to solve this problem?
Problem: i wan to create a program that create and save an excel file....but i dunno how to run a "Save As" dialog box.......????
Common Dialog
I am using MS Common Dialog Control to let the user give the location of a MS Access database that will be used in an Excel-project. Trouble is, once I move the excel-sheet to another PC, it errors, telling me that the MS Common dialog control cannot be found on the computer! I thought this was an OCX-file that was distributed with windows, and that all windows-installation have. Obviously I was mistaken. So my questin is: is there som way I can compile the Excel-file so that it brings the OCX with it? Or can I only use the file on a PC with VB installed (that just doesn't seem right to me...).
Common Dialog Box
hi to all,
just want to ask if there is another tool that functions the same as the common dialog box does? im using excel application and its VB editor to automate it and wen i tryd to add the Common Dialog Component and use it, there is a pop-up notice. it says 'the control could not be created because it is not properly licenced.'
thank you very much!
Common Dialog
Code:
'Pallete
Private Sub cmdColor_Click()
cmndlgColor.ShowColor
End Sub
Ok, after they choose a color from the pallete, is there a way that i can get its r,g,b colors after they click the color palletes OK button?
|