Print command from file rightclick?

D

dymondjack

Hello all, TIA for any input

Is it possible to access the Print command that can be found when
right-clicking a printable file?

I've got a document system that contains various different filetypes (mostly
xls, doc, pdf, dwg and edwg files), and I would like to be able to have the
users open the Print Dialog without having to open the file to print it.

Any ideas? I haven't been able to come up with much online, just examples
of how to print specific filetypes.

In a worst case scenario I can evalute the filetype via code and run the
appropriate function for that type, but if it's possible to somehow read the
registry for the filetype (see if it has an associated 'Print' command) and
execute that command, that would be great.

Thanks again!

--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
 
A

Allen Browne

You might try asking this question in one of the Windows newsgroups. This
group discusses Microsoft Access, the desktop database.

If you are trying to print an Access report, you can drag it from the
Database Window (or Nav Pane in A2007) to the Windows desktop to open it
directly. Or, you can create a macro to print the report directly, and
create a shortcut to the macro.

If VBA code, you can FollowHyperlink to start the registered file type, or
you can ShellExecute:
http://www.mvps.org/access/api/api0018.htm
 
D

dymondjack

I was wondering about a way (in Access) to accomplish the same thing as what
gets done when clicking the Print command from the right-click dropdown.

I am aware of ways to print reports from within access, but the files I am
looking to print are not reports. I am also aware of the ShellExecute API
(which is the current method that I use), but am trying to devise a way to
print these various files without having the user open the file and then
click the print button.

As the OS can apparently print a file without opening it (or open the file
and call the print dialog without user intervention, and close the file
after), I was hoping maybe there was a way to access that particular OS
procedure via Access (perhaps an API?).

I think though, that if this were possible, there would be a lot more people
doing it.

I suppose I can move to the Windows newsgroup and see about a possible
script that can be called from vba, but I was hoping to find something
directly in access.

Thanks for the suggestions.

--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
 
A

Allen Browne

Okay, I'm sure there probably is an API call to perform that report
operation, but I don't know it off the top of my head.

Perhaps you could search at one of the API for VB sites, such as:
http://vbnet.mvps.org/

Or perhaps someone else will have a suggestion for you.
 
R

RoyVidar

dymondjack wrote:
As the OS can apparently print a file without opening it (or open the
file and call the print dialog without user intervention, and close
the file after), I was hoping maybe there was a way to access that
particular OS procedure via Access (perhaps an API?).


"Allen Browne" wrote:


The ShellExecute api, pass it "Print" in stead of vbNullString as
second parameter.

I e - here's an alternation of the code in the link Allen Browne
posted

lRet = apiShellExecute(hWndAccessApp, "Print", _
stFile, vbNullString, vbNullString, lShowHow)

See also http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx

This will sometimes leave an instance of the program printing the file
open/visible - something that usually happens with Acrobat. Here's
one thread I found one elsewhere addressing that issue.
http://www.tek-tips.com/viewthread.cfm?qid=1489448&page=14
 
D

dymondjack

I do believe that is what I am looking for. I wasn't aware that the
ShellExecute API could take a print parameter.

I spent about three hours yesterday searching for a way to do this. I
finally gave up after I found myself trying to decipher some C code for
functions to use the windows spooler <shudder>

thanks guys
--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top