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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not getting prompted to pick printer. Proceeds to print on Windows default

Status
Not open for further replies.

breezett93

Technical User
Jun 24, 2015
128
US
I'm currently moving some programs off of VDOS; so that we can phase out using VDOS. In VDOS, the autoexec file would set the correct printer.

However, when running the program without VDOS, the user does not get prompted to pick which printer should print the document. Instead, it prints to the printer that Windows currently has as default.

I'm searching for the solution that would allow the user to have that standard print window to select a different printer.


Thanks.
 
Visual Foxpro has two default actions when printing a report.

If the printer environment is saved with the report, the report goes to the saved printer. If the printer environment is not saved with the report the report goes to the Windows default printer.

You mention VDOS, and I'm not entirely sure what that is, but it sounds like it's offering some service between the application and the operating system. You won't find a replacement. You also somewhat contractict yourself saying "the auto exec sets the correct printer" and later "the user selects the printer". Which is it?

You need to add the PROMPT keyword to the REPORT FORM commands (and/or make sure there isn't a report environment saved with the report) to get what you're looking for in Windows.
 
You don't say exactly how you are doing the printing. Can we assume that you are doing it via the REPORT FORM command?

If so, then it's simply a matter of adding the PROMPT keyword to the command (as Dan pointed out). But, if you have tried that and it still doesn't print to the correct printer, then make sure the printer environment is not being saved in the report. How you do that depends in which version of VFP you are using (8 or below vs. 9). You can find more information in this article: Trouble-shooting a Visual FoxPro application (under the heading "Problem #5: Printed output goes to the wrong printer").

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
The desired printer is a dot matrix; so it is not using a form to print. The details of what should be printed was hardcoded by the original system designer.

The commands that I currently see in the program are:

Code:
SET DEVICE TO PRINTER
SET PRINTER ON
SET CONSOLE OFF

So I really just need to add prompt in there?

@Dan Sorry for the confusion. They currently do not pick the printer, but VDOS correctly chooses the dot matrix. Removing VDOS causes the default Windows printer to be chosen. So I need to add the bits of code that VDOS was utilizing to the foxpro program.
 
The function you are looking for is GETPRINTER(), which you use in conjunction with SET PRINTER TO NAME:

Code:
lcPrinter = GETPRINTER()
IF NOT EMPTY(lcPrinter)
  SET PRINTER TO NAME (lcPrinter)

  * Do the rest of your processing
ENDIF

The reason to test for NOT EMPTY() is in case the user cancels the printer dialogue.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
After testing, the PROMPT command solved the problem, and we're able to select the correct printer.

Thanks again. One quick final question that probably isn't worth making a new post about:

I'm interested in changing the text size of a couple variables that I am printing with the ? function/command. So for example, one line is:

? vpartno

I'd like to be able to modify the text; so that it isn't the generic 12 pt font when printed. Am I able to do this programmatically?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top