Re: Printing Routine Error
Does the folder c:\DeliveryNote exist on the pc where the problem is occurring?
Does the program have write access to that folder?
Re: Printing Routine Error
Quote:
Originally Posted by
DataMiser
Does the folder c:\DeliveryNote exist on the pc where the problem is occurring?
Does the program have write access to that folder?
c:\DeliveryNote is created in the 'CheckFileExists' routine if not present on the system.
Program has full write access to that directory
Re: Printing Routine Error
What is the exact error and on which line does the error occur?
Re: Printing Routine Error
Quote:
Originally Posted by
Arnoutdv
What is the exact error and on which line does the error occur?
Not an error just a bug i suppose. I get a save PDF dialog box when the following code runs (at Call printDeliveryNote(lngNewInvoice, True, 3)). This should all be automated and run the PDF print in the background (setup in Call SetupBullzip(gstrFileName)). SetupBullZip is a standard routine and works for the invoice and customer advice portions of the invoice prints as expected (IE in the background).
Code:
' invoice and delivery note could be different lengths
' print delivery note once to get number of pages into gintPageNumber
gstrFileName = "c:\DeliveryNote\" & lngNewInvoice & ".pdf"
If CheckFileExists(gstrFileName) Then
Kill gstrFileName
End If
Call SetPrinterToBullzip
Call SetupBullzip(gstrFileName)
Call printDeliveryNote(lngNewInvoice, True, 3)
Printer.EndDoc
Re: Printing Routine Error
Quote:
Originally Posted by
martin_hop
c:\DeliveryNote is created in the 'CheckFileExists' routine if not present on the system.
Program has full write access to that directory
So I take it that means you have checked to confirm that the folder actually exists?
Creating a folder directly off the root can fail and seeing as how the code looks the same for where it works vs doesn't work I would suspect that the path/filename is the issue.
pdf generator may not be able to use the path passed to it so may prompt for one that it can.
That is the only thing I can think of off the top of my head that could explain the results you are seeing.
Have you stepped through the code to see what is happening?
Re: Printing Routine Error
Quote:
Originally Posted by
DataMiser
So I take it that means you have checked to confirm that the folder actually exists?
Creating a folder directly off the root can fail and seeing as how the code looks the same for where it works vs doesn't work I would suspect that the path/filename is the issue.
pdf generator may not be able to use the path passed to it so may prompt for one that it can.
That is the only thing I can think of off the top of my head that could explain the results you are seeing.
Have you stepped through the code to see what is happening?
I've actually got this functioning now. It looks like whilst the directory was being created the code was jumping ahead even with a DoEvents after the dummy print run prior to at actually creating the directory. I added a program pause to test and this cured it. As i do not like using pauses as have seen different results from different systems i've added a quick check loop to ensure the file is created before moving on.
This has raised one other issue i've released (not sure if this should be a new thread), whilst the system now runs the dummy prints correctly, the issue is the real world printers have different print margins, which means at times where the PDF document is for example 3 pages (dummy print) but the physical print document is 4 pages the last page number is now incorrect (the fourth page reads page 4 of 3). I'd previously tried tried running the dummy print to the actual printer and then use printer.killdoc but the system will sometimes send the first page to the printer before cancelling.
My next thought was to use the ShellExecute API and run two PDF prints. The first being the dummy PDF (Doc 1) the second being the actual document (Doc 2). I then used the ShellExecute to print Doc 2 silently in the background to the printer. The only issue with this is currently it sends the document to the default system printer not the printer selected in the VB6 application. Is there a way to tell the ShellExecute to print the PDF silently in the background to the printer selected in the VB program?
Re: Printing Routine Error
Quote:
Is there a way to tell the ShellExecute to print the PDF silently in the background to the printer selected in the VB program?
not with shellexecute, the only way would be to change the system default printer first, then change back
also pdf readers do not seem to be good at printing and closing, adobe reader and some others, often stay open after printing
you should be able to run the dummy print to the output printer, just use killdoc on the first run, get the number of pages then run the actual print to the same printer
Re: Printing Routine Error
Quote:
Originally Posted by
westconn1
you should be able to run the dummy print to the output printer, just use killdoc on the first run, get the number of pages then run the actual print to the same printer
That was my first approach. Unfortunately as some of the prints tend to be large prints the app is sending the printout to the selected print on the dummy run prior to it reaching the Killdoc meaning i am either getting blank pages or part documents printed. The only way to stop this is to set the printer to spool after the print job has finished. I've found no way of doing this at code level (it would need to work for multiple printers) and can't change the numerous workstations as it would mean manually changing each computer and then having to monitor and maintain this as and when new hardware is added. If you have a solution along those lines that would be really handy. Otherwise i'm stuck with changing default printers and shellexecute (which i'd rather avoid if possible)
Re: Printing Routine Error
can you try something like if dummyprint then killdoc at the end of each page, should not affect the counting of pages and may prevent some pages trying to print from the spooler
Re: Printing Routine Error
Quote:
Originally Posted by
westconn1
can you try something like if dummyprint then killdoc at the end of each page, should not affect the counting of pages and may prevent some pages trying to print from the spooler
I've been pulled from this project for a few days although will give that a go when i do get back on it.
Re: Printing Routine Error
Ok so no go with an flag to indicate a dummy print unless i misunderstood. I inserted a killdoc after a new page is generated then the dummy flag was true and i kept getting an error saying printer error.
Code:
Printer.Newpage
PageCount = PageCount + 1
if DummyPrint = true Then
Printer.killdoc
end if
'continue with print routine
Re: Printing Routine Error
Quote:
i kept getting an error saying printer error.
i am not sure why that would be happening, i will try to test some code later
Re: Printing Routine Error
Quote:
Originally Posted by
westconn1
i am not sure why that would be happening, i will try to test some code later
Hi I've approached this with a fresh head today and the flag for a dummy print does work (tooks seconds after a good nights sleep). The Printer error only occurs when printing to OneNote which i use to save paper. Not sure why it would error with OneNote and not the physical printers or PDF printers. Any thoughts on that would be appreciated. I'd like to get to the bottom of that but at least as i'm the only one to use OneNote this will allow me to role out the update.
Thanks for the help.