+ Reply to Thread
Results 1 to 7 of 7

Opening a non-Excel file in Excel with delimiters

  1. #1
    Forum Contributor
    Join Date
    06-25-2013
    Location
    Longview, TX
    MS-Off Ver
    MS365
    Posts
    338

    Opening a non-Excel file in Excel with delimiters

    I am Exporting a report from a system called FPARS (Freight Payment System) and saving it in the folder where it needs to be. Next I need to open it in Excel, using commas as a delimiter. The report saves with the extension "_XLS" and the file type says "File". Is it possible to make my macro open the file using the delimiter or does that part have to be done manually. The File Name won't always be the exact same thing, so I'm thinking that, if it could bring up the Open File box, maybe have the user select the file to open and then have the macro do the rest.

    I tried just opening it with no delimiters and then doing a Text-To-Columns, but certain rows open up with data in columns other than A. I have no idea why.

    Sort of cross-posted, but not explained as well, and haven't had any responses yet: http://www.mrexcel.com/forum/excel-q...g-problem.html

    Thanks!

    Jenny

  2. #2
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: Opening a non-Excel file in Excel with delimiters

    Without an example of the source file... it's hard to provide too much insight... But you can try renaming the source file extension to .csv, and opening that with excel. CSV stands for Comma Separated Values, and is a subformat of a .txt file, recognized by Excel.

    Beyond that, we'd need an example file to work with to provide additional support I believe.
    Going for Guru! Click the Star to the bottom left of this post if I helped!

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Opening a non-Excel file in Excel with delimiters

    Ditto the previous comment. You could probably rename the file extension to .csv in the code before you try to open it.

    Be aware that Excel "remembers" Text to Columns parameters and applies them to subsequent imports. Always best to be specific.

    Workbook, code and sample file would be useful.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Contributor
    Join Date
    06-25-2013
    Location
    Longview, TX
    MS-Off Ver
    MS365
    Posts
    338

    Re: Opening a non-Excel file in Excel with delimiters

    Okay, sorry. I was trying to figure out how to remove sensitive data in the original file while leaving it in the original format. Finally got it, but it won't show up as being available to upload here! So, I put the information into the first column of an XLSX spread sheet (capVisExporttest_XLS - Copy); I hope that helps. capVisExporttest_XLS2 - Copy is how I want it to look right after opening. Once it's open in Excel, I've got my macro doing what I need to finish it. That coding is below. Feel free to tweak that if you see anything.

    Please Login or Register  to view this content.
    Thanks!

    Jenny
    Attached Files Attached Files

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Opening a non-Excel file in Excel with delimiters

    Something like:

    Please Login or Register  to view this content.

    Regards, TMS
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    06-25-2013
    Location
    Longview, TX
    MS-Off Ver
    MS365
    Posts
    338

    Re: Opening a non-Excel file in Excel with delimiters

    Quote Originally Posted by TMS View Post
    Something like:

    Please Login or Register  to view this content.

    Regards, TMS
    Sorry to be so long; I had to go and do my ACTUAL work for a while, LOL!

    I tried that code, replacing the path to the file I want, but it tells me I have the name wrong. I checked several times and I've typed it in correctly.

    Meanwhile, I've Googled the problem and found some (very long) coding that brings up an "Open File" dialog box and lets me select the correct file to open. But I can't get it to correctly delimit the file so that it opens the way it should. Here's that coding:

    Please Login or Register  to view this content.
    It fails on the line:
    Please Login or Register  to view this content.
    and the error is Run-time error '1004': Method 'Cells' of object'_Global' failed.

    Any ideas?

    Thanks!

    Jenny

  7. #7
    Forum Contributor
    Join Date
    06-25-2013
    Location
    Longview, TX
    MS-Off Ver
    MS365
    Posts
    338

    Re: Opening a non-Excel file in Excel with delimiters

    I got it figured out! I pieced together code from here and from Googling stuff & got it doing what I want! It opens an Open File box, lets you select the text file you want and opens it with delimiter - parsing across the spreadsheet into (in this case) columns A-P.
    In case anyone could use this information, here's the coding I put together:
    Please Login or Register  to view this content.
    Thanks for the input!

    Jenny

+ 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. Replies: 2
    Last Post: 05-31-2014, 02:05 AM
  2. Writing Hex character delimiters from an excel file
    By geraldkentschmeer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-19-2013, 12:36 PM
  3. Replies: 4
    Last Post: 01-24-2012, 12:52 PM
  4. [SOLVED] Excel import txt file carriage return as delimiters
    By Gordo T in forum Excel General
    Replies: 5
    Last Post: 08-02-2006, 09:00 AM
  5. saving an excel file as an ASCII text file without delimiters
    By Sewellst in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-07-2005, 10:06 AM

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