Vba - remove filetype (.xlsm) when using 'activeworkbook.saveas'

moni_tm

New Member
Joined
Nov 4, 2015
Messages
29
Good Morning,

I have a macro which takes an existing workbook, makes changes to said workbook and saves a copy of the workbook adding to the existing filename.

The code I currently have takes the existing workbook name including the filetype and then adds the following on the end " - Owner.xlsm"

Example:

Original Filename - "Test.xlsm"
Current New Filename - "Test.xlsm - Owner.xlsm"

Required New Filename "Test - Owner.xlsm

Current Code:

Code:
ActiveWorkbook.SaveAs FileName:=ActiveWorkbook.FullName & " - OWNER.xlsm"


As always, any help, greatly appreciated.

Tom
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
You could use Instrrev to find the last full stop like this:

Code:
Dim sFile as String
sFile = ActiveWorkbook.FullName
sfile = Left$(sFile, Instrrev(sfile, ".") - 1) & " - OWNER.xlsm"
ActiveWorkbook.SaveAs FileName:=sFile, fileformat:=xlOpenXMLWorkbookMacroEnabled

Note that you should include the file type too.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top