Opening a file

J

John

Hi

Via vba, how can I make a file to open in its respective app like word excel
etc.?

Thanks

Regards
 
T

Tom Wickerath

Hi John,

One method is to use the Shell function. Type Shell in a VBA procedure,
highlight the word, and then hit F1 to bring up context sensitive help. The
Shell function requires that you know the path to the executable file. If you
have no guarantee that the path to the executable file will be the same on
all machines, then send me a private e-mail message with a valid return
address. I will share a copy of a function named GetExeFileSpec that can be
used to determine this information.

Tom

QWaos168@XScom cast. Dnet (<--Remove all capitalized letters and spaces).
____________________________________

:

Hi

Via vba, how can I make a file to open in its respective app like word excel
etc.?

Thanks

Regards
 
J

John

Basically I am looking for the equivalent of double clicking on a file name
in windows explorer. I think if you try to open a file, windows
automatically opens the app associated with it.

Thanks

Regards
 
A

Arvin Meyer [MVP]

And that would be the code I pointed out earlier.

To use it, you only need to do something like:

Sub txtFilePath_DblClick(Cancel As Integer)
Dim strPath As String
strPath = Me.txtFilePath

Call fHandleFile(strPath, WIN_NORMAL)
End Sub

Just put the code you see at:

http://www.mvps.org/access/api/api0018.htm

in a standard module and save it. Add an [Event Procedure] for the
double-click event and use the code above.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Top