+ Reply to Thread
Results 1 to 3 of 3

code for opening a file

Hybrid View

ammartino44 code for opening a file 07-29-2015, 05:25 PM
gmr4evr1 Re: code for opening a file 07-29-2015, 05:53 PM
Ed_Collins Re: code for opening a file 07-29-2015, 07:10 PM
  1. #1
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    code for opening a file

    Isn't this code supposed to open a file? It's not working. There is no error but it doesn't open file but then debugs on line input.

    Sub DemoWhileClause()
        ' Page 87 Middle
        Open "C:\Users\amartino\Desktop\invoice.txt" For Input As #1
        r = 1
        Do While Not EOF(1)
            Line Input #FileNumber, Data
            If Not Left(Data, 5) = "TOTAL" Then
                ' Import this row
                r = r + 1
                Cells(r, 1).Value = Data
            End If
        Loop
        Close #1
    End Sub

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: code for opening a file

    Is that the entire code or just a piece of it?
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: code for opening a file

    #FileNumber is not defined in your code. Try Line Input #1, Data

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Opening PDF file via code
    By MarmaladeLover in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-10-2014, 09:19 AM
  2. [SOLVED] VBA code for opening a file with a variable version number in the file name
    By trishcollins in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-04-2014, 04:38 PM
  3. [SOLVED] VB Code to copy without opening the file
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-05-2013, 08:24 PM
  4. [SOLVED] Error in code - play music file automatically after opening file
    By mukeshbaviskar in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-15-2013, 10:06 AM
  5. [SOLVED] VBA-code for opening a file max x times
    By Saturn in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-03-2013, 09:43 AM
  6. [SOLVED] Code for opening file if match with file name is found
    By cokillerliu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2013, 08:41 PM
  7. Having trouble opening an access file using this code.
    By djbummy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2009, 12:37 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1