variables for file names

M

mike

I prompt a user to select the file they want. They do
this for three different files. I would like to create a
variable with the file name only. That way, later in the
program, I would like to refer to the appropriate workbook
based on the file name they selected.

For instance, I would like to do something like this:

Workbooks (vFileName1).Activate or
Workbooks (vFileName2).Close

The variables I have created so far also contain the
path. My variable looks like this:
Workbooks (C:\MyDocs\File1.xls)

Is it possible to create a variable with only the file
name and not the entire path? Thanks for the help.
 
H

Henry

Mike,

Dim Mypath, Myfile as String

Mypath ="C:\MyDocs\"
Myfile ="File1.xls"

Workbooks (Mypath & Myfile).Activate or
Workbooks (Mypath & Myfile).Close

HTH
Henry
 

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

Top