+ Reply to Thread
Results 1 to 2 of 2

GetObject / Inputs from Text file

  1. #1
    Registered User
    Join Date
    11-29-2006
    Posts
    6

    GetObject / Inputs from Text file

    I am trying to get an input from a text file into the VBA code for further analysis. I am trying to use the GetObject function. There is no need to specify the "class" of the file to be opened in certain cases - e.g. if i am opening an excel file - VBA by default assigns the appropriate class. However in the case of a text file (filename.txt) i get an error and my understanding is that the class needs to be specified. What class do i need to specify for opening a text file.
    I hope i have clearly explained my problem. If you need clarifications please post.
    Appreciate your expert advise and responses. Thanks!

    Code below ...

    Set ttinp1 = GetObject("C:\older1\folder2\filename1.xls")
    ' able to execute this command without any errors

    Set ttinp2 = GetObject("C:\folder1\folder2\filename2.txt")
    ' Run-time error '432'
    ' File name or Class name not found during Automation operation

    GrishaP

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning GrishaP

    You don't say what the ultimate object is re the processing of the data, but to bring in data from a text file you should be using the Input # function. The example below will dump the contents of a textfile into the active sheet, but there's no reason why it can't dump it into an array to process :

    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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