My recommendation would be to use the ShellExecute API call, in case the
user would rather have the text file open in some other editor. There's a
complete sample of how to use that API at "The Access Web" as
http://www.mvps.org/access/api/api0018.htm
To let them pick the text file, check out
http://www.mvps.org/access/api/api0001.htm

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> Hi
> How do you launch a text file using a button in VBA?
[quoted text clipped - 3 lines]
> double click on a txt file which then opens in notepad.
> Thanks
John Nurick - 07 Jan 2005 06:12 GMT
>My recommendation would be to use the ShellExecute API call, in case the
>user would rather have the text file open in some other editor. There's a
>complete sample of how to use that API at "The Access Web" as
>http://www.mvps.org/access/api/api0018.htm
AIUI the functional difference between this and
Application.FollowHyperlink only shows up if the file type is not
registered, when ShellExecute lets the user select an application to
open the file with, while FollowHyperlink produces error 486, "no
program is registered to open this file".
>To let them pick the text file, check out
>http://www.mvps.org/access/api/api0001.htm
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
Hi Toby,
There's code at http://www.mvps.org/access/api/api0001.htm to display
the standard File Open dialog so the user can choose a file. Then pass
the filespec returned by the dialog to Application.FollowHyperlink() to
open it. Something like this, oerhaps:
Private Sub cmdOpenTextFile_Click()
Dim strFilter As String
Dim strInputFileName as string
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.TXT)", "*.TXT")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
If Len(strInputFileName) > 0 Then
Application.FollowHyperlink strInputFileName
End If
End Sub
>Hi
>How do you launch a text file using a button in VBA?
[quoted text clipped - 3 lines]
>double click on a txt file which then opens in notepad.
>Thanks
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.