Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default variables for file names

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default variables for file names

Mike,

Dim Mypath, Myfile as String

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

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

HTH
Henry

"mike" wrote in message
...
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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference a file by concatenating cell variables Michael Excel Worksheet Functions 13 October 24th 08 09:54 PM
find maximum and minum variables for multiple names [email protected] Excel Worksheet Functions 1 November 29th 07 10:21 PM
BIG FILE LOTS of Variables that need to be counted Scott@CW Excel Discussion (Misc queries) 1 January 12th 07 10:40 PM
Inserting variables within file names kestrel Excel Worksheet Functions 3 June 16th 06 08:00 PM
Run a Batch file with variables Stuartf Excel Discussion (Misc queries) 1 May 24th 06 04:55 PM


All times are GMT +1. The time now is 03:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"