Link to home
Start Free TrialLog in
Avatar of Prioritypub
Prioritypub

asked on

A macro command that will open an unknown file in a known folder?

I have an Excel file in a folder with a name that will often change. I need to open that file and copy contents from it to another Excel file. I have the macro written to perform all the tasks, except if I don't know what the name of the file will be when the macro is run, so how can I open it?  It will be the only file in this folder, and the folder name will never change.  Is there a command line that will rename the file (without knowing what that file name is) if I know the folder name?
ASKER CERTIFIED SOLUTION
Avatar of mvidas
mvidas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, I should have given you a sample usage of this:

 Dim vFile As String
 vFile = FirstFileName("C:\foldername")
 If Len(vFile) > 0 Then
  Workbooks.Open vFile
 End If

Matt