+ Reply to Thread
Results 1 to 7 of 7

Convert a TXT in XLSX or XLSB without opening the file (VBA)

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    Convert a TXT in XLSX or XLSB without opening the file (VBA)

    Good morning everyone,

    I am trying to convert file that are in TXT into excel document.

    Currently I do the following:

    HTML Code: 
    It works, but it is very slow! Would you know a way to convert these files without opening and saving each of them.

    Any thoughts?

    Thanks in advance for your time.
    Phil

  2. #2
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Convert a TXT in XLSX or XLSB without opening the file (VBA)

    try this file

    open the workbook & go to module and change the path suit to you and run the macro
    Attached Files Attached Files
    Thanks - Naveed
    -----------------------------
    If the suggestion helps you, then Click * to Add Reputation
    To Attach File: Go Advanced>>Manage Attachments>>Add Files (In Top Right Corner)>>SelectFiles>>.........Locate Your File(s)>>Upload Files>>Done (In Bottom Right)
    1. Use [code] code tags [\code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    2. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

  3. #3
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    Re: Convert a TXT in XLSX or XLSB without opening the file (VBA)

    Thanks Naveed!

    I works well. Do you know if there is a way to convert text to excel without using the methods workbook.open. My Data is very large and each time I open, save and close one file it takes a little while.
    I have tried with the function "name file.txt as file.xls" but it does not work.

    Thanks again for your example, I like the way you declare the workbook and worksheet as object. I need to do that more often. I tend to write the whole code everytime.

    Thanks again.
    -Phil

  4. #4
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Convert a TXT in XLSX or XLSB without opening the file (VBA)

    Hi Mortphil

    If the suggestion helps you, then Click * to Add Reputation & give your comments

    about your query just do one thing paste the full path in the code just put the excel file in open mode & hide it & when ever you want to run just run it

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Convert a TXT in XLSX or XLSB without opening the file (VBA)

    Phil

    Have you tried importing the text file via Data>From Text File...?
    If posting code please use code tags, see here.

  6. #6
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    Re: Convert a TXT in XLSX or XLSB without opening the file (VBA)

    thanks Norie.

    Yes I have and it works as well. But I was trying to find a way to convert the file without opening them. It seems that it s not possible.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Convert a TXT in XLSX or XLSB without opening the file (VBA)

    If you are importing then the file isn't opened.

+ 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] Using dir() to select .xlsx and .xlsm but NOT .xls and .xlsb files
    By ccs1981 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-30-2012, 09:46 AM
  2. [SOLVED] xlsx file opening problem
    By avk in forum Excel General
    Replies: 2
    Last Post: 09-17-2012, 01:48 AM
  3. Excel 2007 : xlsx being saved as xlsb?
    By ajmas in forum Excel General
    Replies: 4
    Last Post: 08-27-2012, 11:00 AM
  4. [SOLVED] .xlsb vs .xlsx
    By yamalady in forum Excel General
    Replies: 7
    Last Post: 08-03-2012, 10:27 AM
  5. Excel 2007 : xlsx file opening issues with Excel 2007
    By Sourabh in forum Excel General
    Replies: 0
    Last Post: 10-05-2009, 06:50 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