Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Filename variable | Excel Programming | |||
Converting a Variable Filename to a Constant Filename | Excel Programming | |||
Variable Filename calls | Excel Programming | |||
How do I remove multiple windows of 1 workbook (filename.xls:2,:3 | Excel Discussion (Misc queries) | |||
Filename Variable? | Excel Programming |