Consulting

Results 1 to 5 of 5

Thread: Crazy Request

  1. #1
    VBAX Contributor
    Joined
    Dec 2004
    Posts
    122
    Location

    Crazy Request

    Good morning people, if anybody can help,

    Is it possible with VB in excel to search a folder to find all files with .xls extentions and remove the extenion to nothing. (book1.xls to book1.)

  2. #2
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    This one should to it, it looks for .xls and simply takes the filename up to the .:
    Option Explicit 
    Sub ChangeExt()
       Dim strPath$, strFile$, iPos%
    ' Change this, don't forget the trailing \
       strPath = "e:\test\xls\"
    strFile = Dir(strPath & "*.xls")
    Do While strFile <> ""
          Debug.Print strPath & strFile
          iPos = InStr(strFile, ".xls")
          Name strPath & strFile As strPath & Left(strFile, iPos)
          strFile = Dir
       Loop
    End Sub

    Daniel

  3. #3
    VBAX Contributor
    Joined
    Dec 2004
    Posts
    122
    Location
    Works perfectly, thank you so much

  4. #4
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    No problem, and be sure to mark this thread as solved if it is. To do that, have a look at the top of your first post, there you should see a dropdown menu "ThreadTools" where you can mark this thread solved.

    Daniel

  5. #5
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    Thanks, Steiner.
    I have looking for these code for long.

Posting Permissions

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