Consulting

Results 1 to 5 of 5

Thread: use VBA to covert .xls to .xlsx

  1. #1
    VBAX Newbie
    Joined
    Aug 2011
    Posts
    1
    Location

    use VBA to covert .xls to .xlsx

    I have around 150 excel files in old format ".xls", I want to convert these .xls files to .xlsx format with VBA. Anybody could you please help, is there a way to do this in VBA without opening the old files then saving them as .xlsx? Because in BVA using codes for opening and saving take quite a long time. It would be great if someone konws how to do this without actually opening the old files. Many thanks!

  2. #2
    VBAX Contributor
    Joined
    Jul 2004
    Location
    Gurgaon, India
    Posts
    148
    Location
    Hi,

    [VBA]Sub kTest()

    Dim fName As String
    Dim MyFolder As String

    MyFolder = "C:\Test\" '<<== adjust to suit

    If Right$(MyFolder, 1) <> "\" Then MyFolder = MyFolder & "\"

    fName = Dir(MyFolder & "*.xls")

    Do While Len(fName)
    Name MyFolder & fName As MyFolder & Replace(fName, ".xls", ".xlsx", , , 1)
    fName = Dir()
    Loop

    End Sub[/VBA]
    ________________
    Kris

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What happens if they have macros?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Contributor
    Joined
    Jul 2004
    Location
    Gurgaon, India
    Posts
    148
    Location
    Since the OP wants it to be converted as xlsx, I guess the xls files have no macros.
    ________________
    Kris

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    If he understands that nuance of 2007/2010. Worth asking.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •