Opening an attachment from a form button

honeyshape

New member
Local time
Today, 22:51
Joined
Nov 20, 2008
Messages
9
Ok, so I can use the macro builder to make a button open another form, or report, but....

How do I open an attachment that is in a table. The attachment is a pdf, .docx or .xlsx file.
 
Howzit

I picked this up somewhere along the way. Can't remember where or from who to give the kudos to.

File name (full path) held in a text box (Attach1), and a command button to open the document.

Code in the form
Code:
Private Sub cmdView1_Click() 
Call OpenDocument(Me.Attach1)

End Sub

In a module...
Code:
Public Sub OpenDocument(DocPath As String)
Dim A As Long
A = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & DocPath, vbMaximizedFocus)
End Sub

I have never tried this on Office 2007 documents, but it works on Office2003 and pdfs etc
 
Thanks Kiwiman,

I will try this out after the weekend.
 

Users who are viewing this thread

Back
Top Bottom