Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Remove .xls from a variable filename

I have a CommandButton on a worksheet to create a copy of the
ActiveWorkbook. I want the copy's filename to be the same as the
ActiveWorkbook.FullName but add "_Complete" before the file
extension. i.e......C:\FileName.xls to C:\FileName_Complete.xls.
Any help would be greatly appreciated.

--------------

Regards,

Alan




  #2   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Remove .xls from a variable filename

Hi Alan -

Here's one approach:

fl_Name = ActiveWorkbook.FullName
comp_Name = Replace(fl_Name, ".xls", "_Complete.xls")

--
Jay


"Alan" wrote:

I have a CommandButton on a worksheet to create a copy of the
ActiveWorkbook. I want the copy's filename to be the same as the
ActiveWorkbook.FullName but add "_Complete" before the file
extension. i.e......C:\FileName.xls to C:\FileName_Complete.xls.
Any help would be greatly appreciated.

--------------

Regards,

Alan





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Remove .xls from a variable filename

Thanks a lot Jay. I just can't believe I went so brain dead on this.

--------------

Regards,

Alan



"Jay" wrote in message
...
Hi Alan -

Here's one approach:

fl_Name = ActiveWorkbook.FullName
comp_Name = Replace(fl_Name, ".xls", "_Complete.xls")

--
Jay


"Alan" wrote:

I have a CommandButton on a worksheet to create a copy of the
ActiveWorkbook. I want the copy's filename to be the same as the
ActiveWorkbook.FullName but add "_Complete" before the file
extension. i.e......C:\FileName.xls to C:\FileName_Complete.xls.
Any help would be greatly appreciated.

--------------

Regards,

Alan







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Remove .xls from a variable filename

You could also check to see if it's there.

Dim myNewFilename as string
mynewfilename = activeworkbook.fullname
if lcase(right(mynewfilename,4)) = ".xls" then
mynewfilename = left(mynewfilename,len(mynewfilename)-4)
end if
mynewfilename = mynewfilename & "_complete.xls"



Alan wrote:

I have a CommandButton on a worksheet to create a copy of the
ActiveWorkbook. I want the copy's filename to be the same as the
ActiveWorkbook.FullName but add "_Complete" before the file
extension. i.e......C:\FileName.xls to C:\FileName_Complete.xls.
Any help would be greatly appreciated.

--------------

Regards,

Alan


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Remove .xls from a variable filename

Dave,

I was trying to use RIGHT but just couldn't get it worked out.

Thanks a lot,

Alan



"Dave Peterson" wrote in message
...
You could also check to see if it's there.

Dim myNewFilename as string
mynewfilename = activeworkbook.fullname
if lcase(right(mynewfilename,4)) = ".xls" then
mynewfilename = left(mynewfilename,len(mynewfilename)-4)
end if
mynewfilename = mynewfilename & "_complete.xls"



Alan wrote:

I have a CommandButton on a worksheet to create a copy of the
ActiveWorkbook. I want the copy's filename to be the same as the
ActiveWorkbook.FullName but add "_Complete" before the file
extension. i.e......C:\FileName.xls to C:\FileName_Complete.xls.
Any help would be greatly appreciated.

--------------

Regards,

Alan


--

Dave Peterson





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
Filename variable [email protected] Excel Programming 17 September 4th 06 02:47 PM
Converting a Variable Filename to a Constant Filename Magnivy Excel Programming 2 August 15th 06 06:13 PM
Variable Filename calls Grymjack Excel Programming 0 June 7th 06 05:34 PM
How do I remove multiple windows of 1 workbook (filename.xls:2,:3 Stacey D. Excel Discussion (Misc queries) 2 March 1st 06 09:57 PM
Filename Variable? Penflex Excel Programming 2 May 5th 05 05:11 PM


All times are GMT +1. The time now is 02:34 AM.

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"