How does one open a text file?
Printable View
How does one open a text file?
Open "TESTFILE" For Input As #1
' Close before reopening in another mode.
Close #1
I meant I want to open and see this file...
view it.
VB Code:
Shell "notepad C:\MyFile.txt"
I think this is the bunkiest way to do it...
can i do the following:
Code:On Error GoTo Handle_It
Dim path As String
path = "notepad \\Predator\SOMT\SAPFiles\SOMT_" & Format(Now, "dd-mmm-yy") & ".txt"
Shell path
Done:
Exit Sub
Handle_It:
MsgBox Err.Description, vbCritical, "Error #: " & Err.Number
Resume Done
yep works
thanks
Code:file1$ = "C:\test.txt"
Open file1$ For Input As #1
While Not EOF(1)
Input #1, Doit$
DoEvents
List1.AddItem Doit$
Wend
Close #1
You don't have to lock youself into NotePad. The following code will use whatever tool (Word, WordPad, etc.) is set up to be the default reader for a textfile.
VB 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 ShellExecute Me.hwnd, "open", "c:\marty.txt", _ vbNullString, "C:\", _ 1