Working with directories question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to have amacro that follows a path until it gets to the "Month"
Subfolder. At this point it would check the month against the month in the
folder name and open the releated subfolder where a file will exist that I
would open in much the same way.

Is it possible? What do I need to get started?
 
Hi Helen,
this is a fairly simple method to do what you want. There are more
complex methods to browse each folder in a directory, but this should
get you pointed in the right direction:

Dim folderDate, myDir, myFile, myDirFile As String
'myDir = the directory where the date folder lies
'with folderDate you will need whatever logic
'to derive the naming methodoligy
'myFile = "yourfilename.xls"
myDirFile = myDir & "\" & folderDate & "\" & myFile
Workbooks.Open Filename:=myDirFile, UpdateLinks:=0

If you need more help with the date folder logic please post more
information on the convention used to name it and when the date folder
is added / changes.
HTH--Lonnie M.
 
Do you not know where the month folder is?

if you do

sPath = "C:\mysubfolder1\mysubfolder2\" & format(Date,"mmmm") & "\"

workbooks.Open sPath & Format(Date,"yyyymmdd.xls")

Adjust the Format(Date, . . . ) part to reflect the naming convention for
your file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top