Results 1 to 8 of 8

Thread: text

  1. #1

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492

    text

    How does one open a text file?

  2. #2
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    India
    Posts
    342
    Open "TESTFILE" For Input As #1
    ' Close before reopening in another mode.
    Close #1
    ksm

  3. #3

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    I meant I want to open and see this file...
    view it.

  4. #4
    Hyperactive Member brenaaro's Avatar
    Join Date
    Sep 2001
    Location
    Montreal, Canada
    Posts
    391
    VB Code:
    1. Shell "notepad C:\MyFile.txt"

    I think this is the bunkiest way to do it...
    And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.

  5. #5

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    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

  6. #6

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    yep works
    thanks

  7. #7
    Lively Member
    Join Date
    Jul 2001
    Location
    USA
    Posts
    95
    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

  8. #8
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    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:
    1. 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
    2.  
    3.     ShellExecute Me.hwnd, "open", "c:\marty.txt", _
    4.                                   vbNullString, "C:\", _
    5.                                   1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width