+ Reply to Thread
Results 1 to 2 of 2

Open a file with a button, allow it to be comma delimeted

  1. #1
    Registered User
    Join Date
    05-08-2013
    Location
    Terre Haute, Indiana
    MS-Off Ver
    Excel 2010
    Posts
    13

    Open a file with a button, allow it to be comma delimeted

    Hey guys, I'm pretty new to VBA, only having minimal exposure to it a few months ago. My boss has thrown a complete curve ball at me and I'm not sure how to do this (most of the other code is taken care of ).
    The program: The program will open 2 files (conveniently, ie. no File->Open->All Files->ect..)... where the first file is the output from a program from a test on a subject. The 2nd file is the subjects hear rate during the test. My task is to sync up the files to see if there was increased heart rate during certain stimulus blah blah blah.. that's taken care of, however..

    There are 2 files that need to be opened (I'm assuming 2 buttons, with 2 separate subs would be the best). The only information I need from the first one luckily has a , right before the data. When I import the file and use comma delimited, the file is exactly in the format it needs to be for the current program to work.
    The 2nd file is a list of times a heart beat occurred (5.3\n, ect..).

    I'm not worried about the 2nd file, I feel that is pretty straight forward, but I've spent the better part of my day Googling, Binging, and reading a book in the office on VBA and can't seem to get a grasp on how to open a comma delimited file with a button on the Excel sheet. Any suggestions?

    Sorry if this isn't orthodox, new to VBA, and though I ran across this forum earlier this morning, I finally registered to ask.
    Last edited by skania; 05-08-2013 at 04:05 PM.

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Open a file with a button, allow it to be comma delimeted

    Hi,

    you can open the file and provide the format parameter described by MS here: http://msdn.microsoft.com/en-us/libr.../ff194819.aspx
    e.g.
    Please Login or Register  to view this content.
    where 2 is for CSV file

    or import the file as text, comma separated into excel, that code is produced by the macro recorder:
    Please Login or Register  to view this content.
    where 'TextFileColumnDataTypes ' provides the information about the data type for the columns, so this code will not work for you file, you have to use the macro recorder yourself on the file

    Regards
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

+ 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