Access 2007 related documents

  • Thread starter Thread starter Mark Andrews
  • Start date Start date
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
 
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
 
Ok I'll stick with shell. I think Allen Browne's function helps with the
hyperlink issues.
Mark
 
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
 
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
 
Back
Top