ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Remove .xls from a variable filename (https://www.excelbanter.com/excel-programming/385271-remove-xls-variable-filename.html)

Alan[_2_]

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





Jay

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






Alan[_2_]

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








Dave Peterson

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

Alan[_2_]

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





All times are GMT +1. The time now is 04:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com