Remove .xls from a variable filename

  • Thread starter Thread starter Alan
  • Start date Start date
A

Alan

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.
 
Hi Alan -

Here's one approach:

fl_Name = ActiveWorkbook.FullName
comp_Name = Replace(fl_Name, ".xls", "_Complete.xls")
 
Thanks a lot Jay. I just can't believe I went so brain dead on this.

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

Regards,

Alan
 
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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top