Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / January 2005

Tip: Looking for answers? Try searching our database.

Launch a text file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Toby - 06 Jan 2005 16:42 GMT
Hi
How do you launch a text file using a button in VBA?
I want to click on a button to open a log file - I would
actually like to open a dialog box that starts up in a
particular directory (eg C:\logfile) - the user can then
double click on a txt file which then opens in notepad.
Thanks
Douglas J. Steele - 06 Jan 2005 21:23 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

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.
John Nurick - 06 Jan 2005 21:28 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.