Solved

Printer.copies Crash VB6

Posted on 2004-08-17
12
425 Views
Last Modified: 2008-03-06
I have a program written in vb6, and at the end, i need it to print out the results.  So i compilled, used the package and deployment wizard, installed the program, and it ran fine.  So i created a new user account on the computer so that the midnight shift could use it, without getting at any of my files.  The program works fine, until my program tried to set the number of copies.

The user i added is also an administrator (because of stuff i have yet to sort out, but i'ts not such a problem).  I wrote the program as an administrator.  Here is the problem I"m getting,  when i'm logged in as the new user, If i run the program, and try to print, it crashes, if i'm using the VB IDE, it crashes the entire IDE.  I go back to the account that i wrote the program in, it doent crash and everything works fine.  The line it crashes on is:

Printer.Copies = vliPrnCopies

No warnings, no option to debug, nothing.

Any Ideas?

Ryan
0
Comment
Question by:ryanstarret
12 Comments
 
LVL 20

Expert Comment

by:dsacker
ID: 11820131
Two ideas:

Idea 1:

I'd write out to a log file the value of vliPrnCopies. Could be a number of things, but one thing to rule out is whether there is a non-numeric or empty value in vliPrnCopies.

Simply create a subroutine that opens (in append mode) a log file, writes out a log message, and closes the file. That way you won't lose your log message. Make sure is closes the file each time.

That may suggest another problem if vliPrnCopies turns out to not contain a valid number.

Idea 2:

If you can use the new user's ID, code a "Stop" just before the line that crashes, and check in the immediate window what the value of vliPrnCopies is. Then perhaps you can check some other values in your code. There may be an empty block because of some subtle difference.

That's about all I can suggest. Good luck.
0
 
LVL 4

Expert Comment

by:cachedVB
ID: 11820749
If you want, you can also use a FOR loop, can't you?
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 11822944
Hi,

Here is a known  possiblility,

printer Driver dll is corrupted,

Try uninstalling and reinstaling printer driver(Software).

Also Try getting latest printer driver.
0
 
LVL 1

Author Comment

by:ryanstarret
ID: 11825466
I did a stop before already and checkd the "Printer.copies" on mouseover and it gave me:

"Object variable or with block not set.", and my valie of vliPrnCpoies was 1, ran the line and the IDE crashed, but again, unly when i'm not logged in as the admin that wrote it.

One other thing i tried was using the Common dialog control (VB6 SP5 - so whatever the lates one is, i don't have the computer here so I can't check) which works under both accounts, except, I can't set the number of copies (the copies list box has no effect) and when i click the print button the dialog takes several seconds before returning control to the program, sometimes up to 30sec.  Seems strange to me being that it doesnt seem to do anything other than change the printer and give a visual cue. Has anybod else noticed this?

Thanks to all

Ryan
0
 
LVL 20

Expert Comment

by:dsacker
ID: 11825617
Your Printer object is not being set under that userid ... does he/she have access to that printer? You probably need to put a "Stop" where you are assigning the printer, and see if your userid has some restriction.
0
 
LVL 1

Author Comment

by:ryanstarret
ID: 11833447
The user is another admin in this case.  When i use the m$ common doalog control i can print.

Any clues as to why to common dialog is taking so long when I click print?  It's really annoying...

Thanks

Ryan
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 20

Expert Comment

by:dsacker
ID: 11833590
I'm mentally paging through what I think should be ruled out. But have just a few more possibilities. Are any of the controls and/or references on a LAN drive somewhere? In fact, do you develop off a LAN drive somewhere?

It may be that you should run the code in debug mode, and see if the difference between userids results in the Printer object simply not being "set". If there are any other objects being set, you might as well compare them.

Probably not what you wanted to hear, but this sounds like a "scratch and crawl" problem. Until you find exactly what line of code results in a different "set" or assignment based on the two different users, we're both scratching our heads (as I truly would like to help).

Unless someone else reads this and says, "Oh yeah, this happened to me, too, in this same manner", and can pull a rabbit out of a hat for you, I think your best bet is to find where the code deviates between userids.

Wish I had better for you. Sorry.
0
 
LVL 1

Author Comment

by:ryanstarret
ID: 11834250
Hmmm, not  on a lan drive (yet), in fact, the dev computer doesnt even have a nic... once again, yet.  Everythingis local, and i can print using either account, using the common dialog control, or any other program, so i've switched to the common dialog control.  If there are any ideas with respects to the slowness of the common dialog control, it would be appreciated.

symptom: press print, take a really freakin' long time to get to the next line of code.

here is the setup :

ctlCommDialog.CancelError = True
on error resume next
ctlCommDialog.ShowPrinter
If Err.Number = 32755 Then Exit Sub

So not too complicated there, thats why i'm confused..

Thanks
0
 
LVL 20

Expert Comment

by:dsacker
ID: 11834784
Whatever problems I've encountered not totally unlike this, as a ruling-out method, I've updated my printer driver, and where necessary, downloaded the latest dialog control. I know this is moving into long shots, but that's about all I can think of in terms of ruling out things, without taking a look at your code myself.
0
 
LVL 1

Author Comment

by:ryanstarret
ID: 11835485
Where can i download the latest dialog control?  I would definetely give that a try.

The printer driver is as updated as crappy hp drivers get.

Thanks
0
 
LVL 20

Accepted Solution

by:
dsacker earned 500 total points
ID: 11836125
What is the latest service pack for your Visual Basic? There is SP6 out and available at:

http://www.microsoft.com/downloads/results.aspx?productID=1652D9A4-F0B3-4630-ACD5-56982EA750AB&freetext=&DisplayLang=en

Also on this page are some runtime files, although I don't think these include the common dialog control. While I'm not 100% sure, I think you might find what you need in possible a refresh download of SP5, then download SP6 over on top of that.

Sorry for the trouble you've had to go through on this. Been there, done that, NOOOO fun.
0
 
LVL 1

Author Comment

by:ryanstarret
ID: 12172321
Hmmm, curious... I stopped getting e-mails on this topic.. and missed this one for a long time...

I dont have visual basic anymore..I'm done my work term... but you did try really hard to give me help so you will get the points for a valiant effor which I can't verify the results anymore...

Sorry about the delay... That's unusual.

Ryan
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now