MS Word Macro for Date in File Name

qpwoei

New Member
Joined
Dec 7, 2014
Messages
1
Hi All,

I am completely new to macros (never even heard of them 24hrs ago), and basically just want to have a function to save a document as "Document 1- *todays date*" (eg Document 1- 01.01.2014) in microsoft word.

So far I have been able to achieve this, however when opening the newly named file I get an error message every time..... "We're sorry. We cant open file name because we found a problem with its contents"

The code i have used is.....

Sub Macro1
'
'Macro1 Macro
Dim FilePath As String
Dim NewName As String
FilePath = "C:\Users\Guest\Documents": NewName = FilePath & Format(Date"MM.DD.YYYY") & ".docm"
ActiveDocument.SaveAs Filename:=NewName, FileFormat _
End Sub


Am i on the right path?
Id also like to add a little save button in the document itself at the bottom, which the user clicks on to save using the macro. My research has shown me just how simple this is in MS Excel (draw clip art> right click > assign macro > choose the relevant macro). MS word doesnt appear to be this simple- any simple ways to achieve the same result in the simplest way possible?

Any help would be appreciated! Im a bit lost haha
Thanks

EDIT: Ive been playing around with the code a fair bit and some how changed the second last line (ActiveDocument.SaveAs.......etc) such that it only gives me a syntax error now- any suggestions?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,225,698
Messages
6,186,521
Members
453,361
Latest member
Stacas

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