Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Find File and Rename 39 Points

Posted on 1999-07-17
Medium Priority
Last Modified: 2010-04-30
I need some code which would search for a file. I would need the code to allow for wildcards like *.txt
I would need the code to allow me to rename the file that wa s found to another name and extention, regardless of its properties ie; read only etc. I only have 39 points left.
Thank You
Question by:stnic
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 1525487
This does all but check attributes.

form with drivebox, dirlistbox, filelistbox, txtbox("txtpattern"), txtbox("txtrename"), button("cmdrename"), button("cmdfind")


Option Explicit
Private Sub Form_Load()
txtPattern.Text = "*.*"
txtRename.Text = ""
cmdrename.Caption = "rename"
cmdFind.Caption = "find"
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
File1.Path = Dir1.Path
End Sub

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub cmdFind_Click()
File1.Pattern = txtPattern
End Sub

Private Sub cmdrename_Click()
Dim oldname, newname
oldname = Dir1.Path & "\" & File1.FileName
newname = txtRename
Name oldname As newname
End Sub

Private Sub File1_Click()
txtRename.Text = Dir1.Path & "\" & File1.FileName
txtRename.SelLength = Len(txtRename)
End Sub

LVL 10

Accepted Solution

viktornet earned 60 total points
ID: 1525488
use FindFirstFile() and FindNextFile() for searching for the files needed which also allow wild cards searching... to rename the filename of a file you can use MoveFile().... all of these are Win API calls so you will have to declare them first before using them...


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question