Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Wild Card Path

I would like to write the appropriate code so that I
could save a file based on a current filename:

Example:
The filename is G:\030_Madison.xls
030_Madison is variable with various lengths, so there
are multiple folders such as:

030_Madison
060_Grundy
091_Sangamon

I would like to save my files into the appropriate folder
automatically in the following way.

1. Open the xls file 030_Madison.xls and save it as
G:\030_Madison\030_Madison.txt
2. Open the xls file 060_Grundy.xls and save it as
G:\060_Grundy\060_Grundy.txt

This is not a loop, I just want to be able to save the
xls file with the same name and in the appropriate folder.

Any assistance would be greatly appreciated.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Wild Card Path

Dim sName as String
sName = left(ActiveWorkbook.Name,len(Activeworkbook.Name)-4)
ActiveWorkbook.SaveAs FileName:="G:\" & sName & "\" & sName & ".txt", _
FileFormat:=xlText

Change the fileformat to the appropriate xlconstant (xlText,xlCSV, etc).

--
Regards,
Tom Ogilvy

"Chris Sergent" wrote in message
...
I would like to write the appropriate code so that I
could save a file based on a current filename:

Example:
The filename is G:\030_Madison.xls
030_Madison is variable with various lengths, so there
are multiple folders such as:

030_Madison
060_Grundy
091_Sangamon

I would like to save my files into the appropriate folder
automatically in the following way.

1. Open the xls file 030_Madison.xls and save it as
G:\030_Madison\030_Madison.txt
2. Open the xls file 060_Grundy.xls and save it as
G:\060_Grundy\060_Grundy.txt

This is not a loop, I just want to be able to save the
xls file with the same name and in the appropriate folder.

Any assistance would be greatly appreciated.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Wild Card Path

Chris,

Dim myFN As String
myFN = Replace(ActiveWorkbook.Name, ".xls", "")
ActiveWorkbook.SaveAs "G:\" & myFN & "\" & myFN & ".txt", xlText

HTH,
Bernie
MS Excel MVP

"Chris Sergent" wrote in message
...
I would like to write the appropriate code so that I
could save a file based on a current filename:

Example:
The filename is G:\030_Madison.xls
030_Madison is variable with various lengths, so there
are multiple folders such as:

030_Madison
060_Grundy
091_Sangamon

I would like to save my files into the appropriate folder
automatically in the following way.

1. Open the xls file 030_Madison.xls and save it as
G:\030_Madison\030_Madison.txt
2. Open the xls file 060_Grundy.xls and save it as
G:\060_Grundy\060_Grundy.txt

This is not a loop, I just want to be able to save the
xls file with the same name and in the appropriate folder.

Any assistance would be greatly appreciated.




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
how to use wild card in if funtion doyree Excel Discussion (Misc queries) 3 February 4th 08 08:39 PM
Wild Card Vlookups [email protected] Excel Discussion (Misc queries) 2 January 7th 08 07:27 PM
Wild card * Herman Excel Worksheet Functions 0 October 21st 05 01:39 PM
Wild Card and Dates hkslater Excel Worksheet Functions 2 November 12th 04 09:16 PM
Wild card in if then statements jstocka Excel Programming 5 April 29th 04 04:10 AM


All times are GMT +1. The time now is 08:14 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"