Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printer problem (easy star to whom solves it) 2

Status
Not open for further replies.

OrthoDocSoft

Programmer
May 7, 2004
291
US
Compadres:

My app in my development environment, with the following code:

Code:
Me.PrintForm
Printer.EndDoc

works just fine. At my client's site, it doesn't.

Why?

I get: "Run-time error 342 (not sure on the number 342, if it's important to you, I will tell you exactly), Printer Error"

I am developing on XP. Client is Windows 2000 professionsl. Easy star for the first correct answer.

Ortho

[lookaround] "you cain't fix 'stupid'...
 
The exact Error number would be useful. If it is a 342 have you checked out vbhelp on it and your Control arrays.

Your code working fine for me (.exe) on Win 2000 when I create a minimal test project with it under a command button.
 

1. You should post the exact number and error message...

2. Why are you calling Printer.EndDoc ??
The PrintForm uses it's own device context.
 

Yes, just last week a similar problem occured on a vitual machine was reported and was because a printer wasn't even installed...
 
>2. Why are you calling Printer.EndDoc ??
>The PrintForm uses it's own device context.

No, that changed for VB6; PrintForm uses the DC of the Printer object, which means that PrintForm now should pick up any print setting changes that you make to the Printer. However it is (a bit) buggy, and EndDoc is a workaround ...
 
S Berthold -- I am calling Printer.enddoc Because I read somewhere that older operating systems (like Windows 2000) require it.

The Vampire -- There is a printer attached, which works with word and windows explorer. I will ask the administrator if it is "set as default."

Thanks,

Ortho



[lookaround] "you cain't fix 'stupid'...
 
I don't know if this applies to VB6, but with Access reports whenever I have a printer problem it is invariably the printer driver, and usually the fix is to update the driver

 
>I am calling Printer.enddoc Because I read somewhere that older operating systems (like Windows 2000) require it.

ah yes. I do not use it and didn't know it changed strongm.

>No, that changed for VB6
Or was it a service pack of VB6? I only ask because of an article I read.

OrthoDocSoft, just to test, have the user where the problem occurs install the same printer as on the machine where it does work and then set it as the default printer to see if error occurs (they of course do not need to have printer physically available)
 
I never use PrintForm in real apps and have only had Error 482s in 'userland' a couple of times; both times it was on an HP 870 cxi when using the VBPrnDlg.dll; updating the users printer driver cured the problem.
 
Ortho, why dont you use the common dialog so that you can see the printer you are sending the info to?

i.e.

CommonDialog1.ShowPrinter
Printer.Copies = CommonDialog1.Copies
Me.PrintForm
Printer.EndDoc

I appologise if this code looks like crap but i am a novice. I don't know that this will fix your problem as it sounds more like a driver issue to me, but it will give you more options as to where and how many to print.

This is an extract from the MSDN Library:

Visual Basic Reference

Not enough room to allocate control array 'item' (Error 342)
See Also

There isn't enough memory to create all the elements of a control array. This error has the following causes and solutions:

An element in a control array with discontiguous index values for its elements, such as 0, 2, 4, was assigned too large an index value at design time.
Change the Index propertys setting to a smaller value so that Visual Basic doesn't run out of memory.

You used the Load statement to add an element with too large an index value to a control array.
Change the index value in your code to a smaller value.

Hope this all helps...
 
dedo8816 and others,

First of all APOLOGIES for putting in a "dummy" error code which few of you actually tried to address. As I corrected in an earlier post, the actual error was "482," so, dedo, sorry that you spent time on that. I will never do that again.

Dedo, implemented your code, but then the user HAS to press "print" and I am trying to create an "AUTOPrint" functionality for hands-free operation (as much as possible).

I will see what your code does for my app, tho, and will report back.

[lookaround] "you cain't fix 'stupid'...
 
HughLerwill,

What DO you use in "real apps," please?

Thanks,

Ortho

[lookaround] "you cain't fix 'stupid'...
 
>What DO you use...

I print reports rather labouriously to the printer object, and/ or a picture box for print previews.

If a printout of a Form is required Alt-PrntScrn is always there to pop a copy of its image into the clipboard.
 
OK. I went to the support.microsoft.com link you all recommended and found the API bit that puts everything in a picturebox and prints it. It works just fine as a stand-alone project.

I then:
1) imported the module (not the form) into my app without any modifications, then,
2) added a picturebox (picture1) onto the form I want to print (Form2), then
3) copied the few lines below into my "Form2.PrintForm" routine:

Code:
'Form2.PrintForm sub

Me.Show

Set Picture1.Picture = CaptureForm(Me)
PrintPictureToFitPage Printer, Picture1.Picture
Printer.EndDoc

which is verbatim from the article.

Problem is Form1.SomeSub calls Form2.PrintForm. As I've shown above, Me.Show is performed first, and Form2 appears on the screen as desired, but I don't think form2's handle is active when the print API bit is called, and PrintForm prints the screen full of the other forms (Form1 included), rather than Form2! I'm not very smart about handles, but someone I'm sure knows how to fix this. I tried this:

Code:
'Form1.SomeSub

Me.Hide

Form2.PrintForm

Me.Show

but that didn't help (Form1 still prints as part of the screen contents). I apologize for using the word "easy" in the title of this thread.

Please help.

Thanks,

Ortho

[lookaround] "you cain't fix 'stupid'...
 
Sorry, I got the above bit to work by adding some "DoEvents." I will try this out in clientworld and get back to you all.

Ortho.

[lookaround] "you cain't fix 'stupid'...
 
Clientworld: Doesn't work.

I get the error:

Runtime error '482'
Printer error

I compiled the program I got from the microsoft article referenced above, and tried it in clientworld. It also didn't work, and gave the same error. Does anyone know what might be wrong?

Thanks,

Ortho


[lookaround] "you cain't fix 'stupid'...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top