I'm trying to get a Word form to automatically insert the name and date into the filename when I save it. I don't know much programming but have pieced together the following:
Sub FileSave() ' ' FileSave Macro ' Saves the active document or template ' With Application.Dialogs(wdDialogFileSaveAs) SendKeys "%n" & " " & ActiveDocument.ContentControls(1).Range.Text & " " & ActiveDocument.ContentControls(2).Range.Text & " " & ActiveDocument.ContentControls(14).Range.Text & " " & Format(Date, "mm-dd-yy") .Show
End With End Sub
It mostly works but the macro seems to evoke on every word doc if I try to save. I get an error as it can't find the form fields. How do I get it to only activate on the template form i have?
Also a really really weird bug is that it will randomly delete 0-3 characters in the beginning. For example if the first name is Michael, it will sometimes show ichael or chael. It would be totally random how many it would remove. That is why i put three spaces in the beginning to just help quell the bug a little.
Any tips would be much appreciated!
Sub FileSave() ' ' FileSave Macro ' Saves the active document or template ' With Application.Dialogs(wdDialogFileSaveAs) SendKeys "%n" & " " & ActiveDocument.ContentControls(1).Range.Text & " " & ActiveDocument.ContentControls(2).Range.Text & " " & ActiveDocument.ContentControls(14).Range.Text & " " & Format(Date, "mm-dd-yy") .Show
End With End Sub
It mostly works but the macro seems to evoke on every word doc if I try to save. I get an error as it can't find the form fields. How do I get it to only activate on the template form i have?
Also a really really weird bug is that it will randomly delete 0-3 characters in the beginning. For example if the first name is Michael, it will sometimes show ichael or chael. It would be totally random how many it would remove. That is why i put three spaces in the beginning to just help quell the bug a little.
Any tips would be much appreciated!
