Opening Non MS applications and print files from VB

G

G

I am currenting using a Module in Access2k to open and populate bookmarked
MS Word documents and print them. This works great and is a huge time saver.

I would like to open some non-microsoft files (*.pdf, *.dwg) with the native
applications for printing. I can extract the fileNames with an ADO procedure
from a SQL datastore. Not sure if this is possible. No modiifications to
the files are required, just printing. Currently this is a time consuming
non automated process.

Any Ideas?

thanks for the responses.

G
 
L

Lars-Eric Gisslén

Garret,

You can try the ShellExecute() Win API function.
--------------------------
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

sub Test()
nResult = ShellExecute(0, "print", "myfile.pdf", "", "", 1)
If nResult <= 32 Then
MsgBox "Sorry, failed to open an associated application for
myfile.pdf"
End If
End Sub
--------------------

You can normally find out if you can use the 'Print' operation by right
clicking on a file with the extension you want to print in the Windows
Explorer. If the Print option is available in the popup meny you should be
able to use ShellExecute
 
G

G

Lars-Eric,
Thanks. I will give this a try. This will be the first time I have used the
shell32.dll. Know of any good sites that with documentation.

Garret
 
L

Lars-Eric Gisslén

Garret,

Sorry for replying so late but I've been in Kirkland/Seattle for learning
some new MS technology.

The best place for getting information about Windows API is the MSDN site,
http://msdn.microsoft.com

The search features is not the best at that site but all information you
will ned is there, even if quite hidden sometimes.
 

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

Top