SetAsDefaultPrinter Issue
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
-
- User
- Posts: 8
- Joined: Wed Oct 03, 2012 3:23 pm
SetAsDefaultPrinter Issue
Hi,
I am looking at an issue with our VB6 code, the code has worked previously with no issue.
The problem is we are trying to save a .doc file as a .pdf silently in a sub-routine, but it seems that the default printer is not being set up properly and the document just gets printed on the default printer.
The command to save this document to a .pdf is Shellexecute 0, "printto" , "c:\path\temp.pdf" , """" + printername + """" , vbnull, SW_MINIMIZE
If I stop the code before this line above and check my printers, my new printer is there but not set as the default printer, if I then set this manually then the .pdf file is saved to correct directory.
Cheers
I am looking at an issue with our VB6 code, the code has worked previously with no issue.
The problem is we are trying to save a .doc file as a .pdf silently in a sub-routine, but it seems that the default printer is not being set up properly and the document just gets printed on the default printer.
The command to save this document to a .pdf is Shellexecute 0, "printto" , "c:\path\temp.pdf" , """" + printername + """" , vbnull, SW_MINIMIZE
If I stop the code before this line above and check my printers, my new printer is there but not set as the default printer, if I then set this manually then the .pdf file is saved to correct directory.
Cheers
- Tracker Supp-Stefan
- Site Admin
- Posts: 17948
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: SetAsDefaultPrinter Issue
Hello northgate information solutions,
A possible solution would be to change the default printer to what you want, print to it and then restore the default to what it was before you "printed".
There are samples of such methods in e.g. the C# sample projects, and the same should be available in the VB6 ones as well.
Regards,
Stefan
A possible solution would be to change the default printer to what you want, print to it and then restore the default to what it was before you "printed".
There are samples of such methods in e.g. the C# sample projects, and the same should be available in the VB6 ones as well.
Regards,
Stefan
-
- User
- Posts: 8
- Joined: Wed Oct 03, 2012 3:23 pm
Re: SetAsDefaultPrinter Issue
I think you misunderstood me, I have 4 printers installed, my default printer is P1, I create a pseudo printer PDF5X and set up options for this printer and then I try and save my word document as a .PDF through the printer PDF5X. In my code I have already set the default printer using PDFPrinter.SetAsDefaultPrinter, but my default printer never changes to the PDF5X.
- Tracker Supp-Stefan
- Site Admin
- Posts: 17948
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: SetAsDefaultPrinter Issue
Thanks for the extra details northgate information solutions,
You also need to make sure that
PDFPrinter.ApplyOptions(0);
Is called after SetAsDefaultPrinter(), and before actually starting sending data for printing.
Regards,
Stefan
You also need to make sure that
PDFPrinter.ApplyOptions(0);
Is called after SetAsDefaultPrinter(), and before actually starting sending data for printing.
Regards,
Stefan
-
- User
- Posts: 8
- Joined: Wed Oct 03, 2012 3:23 pm
Re: SetAsDefaultPrinter Issue
Hi Stefan,
the PDFPrinter.ApplyOptions(0) was set.
the PDFPrinter.ApplyOptions(0) was set.
-
- User
- Posts: 8
- Joined: Wed Oct 03, 2012 3:23 pm
Re: SetAsDefaultPrinter Issue
Hi Stefan,
long time no hear!!!
I have re-wrote the sub-routine to use MS word object!!!
long time no hear!!!
I have re-wrote the sub-routine to use MS word object!!!
- Tracker Supp-Stefan
- Site Admin
- Posts: 17948
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: SetAsDefaultPrinter Issue
Hello northgate information solutions,
I passed this to a colleague of mine last night, but have not yet received feedback from him.
Is your latest post meaning that you got things running as expected now?
Regards,
Stefan
I passed this to a colleague of mine last night, but have not yet received feedback from him.
Is your latest post meaning that you got things running as expected now?
Regards,
Stefan
-
- User
- Posts: 8
- Joined: Wed Oct 03, 2012 3:23 pm
Re: SetAsDefaultPrinter Issue
Hi Stefan,
my latest post means that I had to write a workaround to bypass your potential bug.
I am now looking into using MS word plugin to achieve this and bypass using your library.
Thanks
my latest post means that I had to write a workaround to bypass your potential bug.
I am now looking into using MS word plugin to achieve this and bypass using your library.
Thanks
- Tracker Supp-Stefan
- Site Admin
- Posts: 17948
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: SetAsDefaultPrinter Issue
Hi northgate information solutions,
I am trying to get some further advise for your case from my colleagues!
Regards,
Stefan
I am trying to get some further advise for your case from my colleagues!
Regards,
Stefan
- Ivan - Tracker Software
- Site Admin
- Posts: 3550
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
- Contact:
Re: SetAsDefaultPrinter Issue
Can you please let us know the OS you are using?
Tracker Software (Project Director)
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
-
- User
- Posts: 8
- Joined: Wed Oct 03, 2012 3:23 pm
Re: SetAsDefaultPrinter Issue
Developed on XP with service pack 3
- Tracker Supp-Stefan
- Site Admin
- Posts: 17948
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: SetAsDefaultPrinter Issue
Thanks northgate information solutions,
Passed that to Ivan, and he will follow up with you later.
Regards,
Stefan
Passed that to Ivan, and he will follow up with you later.
Regards,
Stefan