Access 2007 related documents

M

Mark Andrews

I have an Access2007 database and am storing paths to files in a table.
Example: a single customer might have 5 external files that are related to
the customer
I decide not to store the files themselves in the database in an attachment
field for various reasons.

Everything seems to work ok I just have one question:

To open the file (Note: I do not know what type of file will be in the
list), I am using this code:

Private 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 Function OpenDoc(ByVal DocFile As String) As Long
OpenDoc = ShellExecute(0&, vbNullString, DocFile, vbNullString,
vbNullString, vbNormalFocus)
End Function

Is this the best way to trigger files to open from Access? I tried a few
examples (word, excel, txt) and it seems to work.

I noticed Allen Browne has a function for opening a file from a hyperlink as
an alternate method.

Just looking for an expert opinion on the best method,
Thanks,
Mark
 
J

Jeanette Cunningham

I find that both methods work.
Hyperlinks are usually fine, sometimes there are issues with an error
message about hyperlinks harming your computer, and these can sometimes be
difficult to remove.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
M

Mark Andrews

Ok I'll stick with shell. I think Allen Browne's function helps with the
hyperlink issues.
Mark
 
H

helenelaplante\\

Mark Andrews said:
I have an Access2007 database and am storing paths to files in a table.
Example: a single customer might have 5 external files that are related to
the customer
I decide not to store the files themselves in the database in an
attachment field for various reasons.

Everything seems to work ok I just have one question:

To open the file (Note: I do not know what type of file will be in the
list), I am using this code:

Private 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 Function OpenDoc(ByVal DocFile As String) As Long
OpenDoc = ShellExecute(0&, vbNullString, DocFile, vbNullString,
vbNullString, vbNormalFocus)
End Function

Is this the best way to trigger files to open from Access? I tried a few
examples (word, excel, txt) and it seems to work.

I noticed Allen Browne has a function for opening a file from a hyperlink
as an alternate method.

Just looking for an expert opinion on the best method,
Thanks,
Mark
 
D

De Jager

Mark Andrews said:
I have an Access2007 database and am storing paths to files in a table.
Example: a single customer might have 5 external files that are related to
the customer
I decide not to store the files themselves in the database in an
attachment field for various reasons.

Everything seems to work ok I just have one question:

To open the file (Note: I do not know what type of file will be in the
list), I am using this code:

Private 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 Function OpenDoc(ByVal DocFile As String) As Long
OpenDoc = ShellExecute(0&, vbNullString, DocFile, vbNullString,
vbNullString, vbNormalFocus)
End Function

Is this the best way to trigger files to open from Access? I tried a few
examples (word, excel, txt) and it seems to work.

I noticed Allen Browne has a function for opening a file from a hyperlink
as an alternate method.

Just looking for an expert opinion on the best method,
Thanks,
Mark
 

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