PDA

View Full Version : File.Print() Question


tigran
05-14-2008, 01:31 PM
It appears that File.Print() function acts differently on different machines. Here is what I experience:

1. If the function is called for the first time on the machine that has Microsoft Word installed but never used, then the function throws "File Not Found" error, even though the file to print exists. Calling the function again doesn't produce an error and works OK

2. Calling the function that has at least one printer designated as "default printer" launches the file in Microsoft Word and prints it.

3. Calling the function that doesn't have a designated default printer opens a "Print Dialog" which allows the user to select a printer and start printing

Why is this happening? What logic the function uses to determine whether to display Print Dialog or whether to open the document in Microsoft Word and print from there?

jassing
05-14-2008, 07:16 PM
I'm guessing your using a .doc file or your file.print() target...

how it works, i assume, is by using the windows api ShellExecute() which can open or print a file.

The system looks for the association for the file (.doc in your case) and finds the application (word) if it has a "print" action associated with it (in the registry) it then calls the application with the document and asks it to print.

If there's no default printer to print -- what would you have it do? print to all?

the reason it fails the 1st time word is run is becuase word needs to have you accept or reject some terms.... the 2nd time doesn't need that agreement to happen.

What you're experiencing seems 100% normal to me.