VBA to 'Save As' not working

Mel Smith

Well-known Member
Joined
Dec 13, 2005
Messages
1,023
Office Version
  1. 365
Platform
  1. Windows
I am trying include code to Save As .xlsm but it doesn't save a usable file. It saves the file as intended but not as Excel.xlsm or anything else. In fact the newly saved file cannot be opened...

The code I have used is:

Dim Fname As String
Fname = ActiveWorkbook.Name & Format(Date, "ddmmyy")
ActiveWorkbook.SaveAs "C:\Users\melsm\Documents" & Fname, 52

Is there anything missing from my code or is there another way to achieve what I'm trying to do?

Many thanks.

Mel
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Further to my previous post; I missed out Dim ReportDate As String. I have also realised that the unusable file is being save with a file extension .xlsm050118 whereas what I'm after is the file name (which is MRS Sorting Template to be saved as MRS Sorting Template 050118.xlsm (and tomorrow as ....060118.xlsm).

Mel
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,426
Members
448,961
Latest member
nzskater

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