Print an external file

  • Thread starter שמוליק
  • Start date
×

שמוליק

how can i Print an external file(doc, xls, pdf) from access?

thanks
sam
 
T

Tom van Stiphout

On Tue, 11 May 2010 05:23:00 -0700, ??????

You could use the ShellExecute windows api function, with the Print
verb. Look it up in your favorite Search engine.

-Tom.
Microsoft Access MVP
 
D

Daniel Pineault

I found the following function a while back. The original source is
indicated, but the link no longer works?!

'Source: http://www.pacificdb.com.au/MVP/Code/ExeFile.htm
Public Const SW_HIDE = 0
Public Const SW_MINIMIZE = 6
Public Const SW_RESTORE = 9
Public Const SW_SHOW = 5
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOWNORMAL = 1

Public 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

Public Sub ExecuteFile(sFileName As String, sAction As String)
Dim vReturn As Long
'sAction can be either "Open" or "Print".

If ShellExecute(Access.hWndAccessApp, sAction, sFileName, vbNullString,
"", SW_SHOWNORMAL) < 33 Then
DoCmd.Beep
MsgBox "File not found."
End If
End Sub
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 

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