Results 1 to 6 of 6

Looping a macro over all files in a folder for a file conversion

Threaded View

  1. #1
    Registered User
    Join Date
    03-09-2011
    Location
    Victoria, British Columbia
    MS-Off Ver
    Excel 2003
    Posts
    13

    Looping a macro over all files in a folder for a file conversion

    Hello there,

    I faced with the task of converting thousands of files with the suffix .asc. These are outputted data files with the standard rows and column of numbers. I would like to be able convert these files into .xls files using a macro. However, I really am not too sure how to loop a macro to run on all files within the folder that the .xls macro file currently resides.

    So for example, if I have C:\Temp with all the .asc files in it and then the .xls macro is within C:\Temp, I would like be able to run the macros to convert all those .asc files into .xls files. Below is a start of some of what I would like done except for this is on a single file. Can anyone recommend a good way to proceed with this?

    Thanks in advance

    Sub Import()
    '
    ' Import Macro
    '
    
    '
        ChDir "Z:\Link to lisst_infil\import_macro"
        Workbooks.OpenText Filename:= _
            "Z:\Link to lisst_infil\import_macro\L2231402.asc", Origin:=437, StartRow:= _
            1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
            ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False, Comma:=False _
            , Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array _
            (3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), Array( _
            10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15, 1), Array(16, 1), _
            Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), Array(22, 1), Array( _
            23, 1), Array(24, 1), Array(25, 1), Array(26, 1), Array(27, 1), Array(28, 1), Array(29, 1), _
            Array(30, 1), Array(31, 1), Array(32, 1), Array(33, 1), Array(34, 1), Array(35, 1), Array( _
            36, 1), Array(37, 1), Array(38, 1), Array(39, 1), Array(40, 1), Array(41, 1), Array(42, 1)) _
            , TrailingMinusNumbers:=True
        ActiveWorkbook.SaveAs Filename:= _
            "Z:\Link to lisst_infil\import_macro\L2231402.xls", FileFormat:=xlNormal, _
            Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
            CreateBackup:=False
    End Sub
    Last edited by hippie_dream; 03-10-2011 at 12:11 PM.

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