SaveAs("testing.xlsm") wont be accepted

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I opened a new excel file and wrote the code below. When I ran the code, excel give me this message:
"the following feature couldn't be saved in macro-free workbooks.. to save click no ..."

https://www.dummies.com/wp-content/uploads/215281.image0.jpg

Why I got that message. If you see the code I am SavingAs ("testing.xlsm") .. the file extension has m (for macro)?
but anyway, if I click yes or no to that message, it wont save!! Thank you.

++++
Sub newone()
ThisWorkbook.SaveAs ("testing.xlsm")
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
You need to seperate the filename from the file extension !

Code:
Sub newone()
ThisWorkbook.SaveAs Filename:="Testing" & ".xlsm"
End Sub
 
Upvote 0
Thanks for your reply. Sorry what := does it do? is it part of the FileName synatax. I once somehow managed to run my code without doing the FileName stuff. Not sure why this time is not running. Thank you once again
 
Upvote 0
If the workbook has not been saved before, you need to specify the path. For example :

ThisWorkbook.SaveAs Filename:="D:\Documents\Testing.xlsm"
 
Upvote 0
If saving a file with macros, you may also need to specify the FileFormat. Do some research on the SaveAs method, here for example.
 
Upvote 0
Hello all, I just saved a new workbook and then run my code and it did work. So it does work if the file is not save the first time, not sure why? Thank you.

Sub newone()
ThisWorkbook.SaveAs ("testing.xlsm")
End Sub
 
Upvote 0
As Peter said, you need to specify the fileformat argument.
 
Upvote 0
Sorry, I meant I save the file manually by going to file-->save then changed the extension to xlsm (select macro) and then went to run my code.
Thanks
The second statement doesn't seem to follow from the first since you said you did save the workbook before running the code.
 
Upvote 0
As both Peter and Rory have stated you need to specify the file format. Please read/reread the link Peter posted in post number 5.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,198
Members
453,022
Latest member
RobertV1609

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