|
-
Sep 28th, 2009, 05:32 AM
#1
Thread Starter
Member
[RESOLVED] Open File in Notepad
Good Afternoon!
I have a question!
I am working in MS Access and have a Switchboard with 3 buttons. 1. Opens the Open Windows, 1 Loads it and the last 1 exit's the application.
How can I Open a .txt file with Notepad?
Here's what I got so far:
Option Compare Database
Private Sub btnOpenFile_Click()
'Instantiate an open-file dialog.
'
Dim myFileDialog As FileDialog
Set myFileDialog = Application.FileDialog(msoFileDialogFilePicker)
With myFileDialog
'
' Single selection only. Let him pick .txt, .csv and .xls files.
'
.AllowMultiSelect = False
.Title = "Import-Datei auswählen"
.Filters.Clear
.Filters.Add "Alle Dateien", "*.*"
.Filters.Add "Textdateien", "*.txt"
.Filters.Add "Trennzeichen getrennte Datei", "*.csv"
.Filters.Add "Excel Dokument", "*.xls"
.Filters.Add "Excel 2007 Dokument", "*.xlsx"
On Error Resume Next
'
' As a default, put the name we're currently using as the initial file name.
'
.InitialFileName = "KitLink_II"
On Error GoTo 0
.Show
End With
'
' We're back? Let's try to put the selected file name into the import file text box.
' If this doesn't work (e.g.: nothing selected, open file dialog cancelled, etc.),
' we're done.
'
Me.txtImportFile.SetFocus
On Error Resume Next
Me.txtImportFile.Text = myFileDialog.SelectedItems(1)
On Error GoTo 0
'
' Did he select something?
'
If Err = 0 Then
'
' Yes. Having put the current name in the ImportDatei text box, have DateiInfoLesen
' show the file details.
'
End If
On Error GoTo Err_open_file_Click
Dim fso, MyFile
Dim linetxt As String
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile("C:\Users\Michael.Speicher\Documents\KitLink_II.mac", 1)
linetxt = MyFile.Readline
MsgBox linetxt
Exit_open_file_Click:
Exit Sub
Err_open_file_Click:
MsgBox Err.Description
Resume Exit_open_file_Click
End Sub
When I click Open it just opens the first line of the document in a MessageBox!?
Thanks
Michael
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|