Save File Annoyances (Date and Macro Free)

elcid99

New Member
Joined
Mar 6, 2015
Messages
4
I have two annoyances in the macro below. The first is, I would like to append todays date at the end of the filename (mm-dd-yyyy). Everywhere I look online, I see a Format (Now or DateTime.Now). Whenever I run the command, I get a "Wrong number of arguments or invalid property assignment" error. I'm using Office 2010. The second issue is I would like for the file to be saved without any macros in it. I tried the Fileformat=51 option. It saves it with the macros disabled, but they are still there. Thanks for any help.

Code:
   Sub Save_File()
       Dim SaveName As String
       Dim WSHShell As Object
       Dim DesktopPath As String
       Dim Today As String
      ' Today = Format(DateTime.Now(), "mm-dd-yyyy")
       Set WSHShell = CreateObject("WScript.Shell")
       DesktopPath = WSHShell.SpecialFolders("Desktop") & "\Data"
       SaveName = ThisWorkbook.Worksheets("Data").Range("Z1").End(xlDown).Text & "_" & ThisWorkbook.Worksheets("Data").Range("Z2") & "_Comparison" & " " & Format(DateTime.Now(), "mm-dd-yyyy")
       ActiveWorkbook.SaveAs DesktopPath & "\" & SaveName & ".xls"
       Set WSHShell = Nothing
   End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I really only have 1 issue, adding the date to the filename. If anyone has suggestions, I would appreciate that. The macro free issue was a result of blurry eyes and too many test files open with similar names.
 
Upvote 0

Forum statistics

Threads
1,215,047
Messages
6,122,858
Members
449,096
Latest member
Erald

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