This project is read-only.

Request Macros

Aug 25, 2009 at 9:39 PM

Please use this board to request any functionality not already covered by existing macros in this project.

Mar 26, 2011 at 7:48 PM

A request was recently emailed to me to create some way to allow MS Word Documents to be saved according to the first line of text and the current date.  I've now made a template to do this, available here: Word SaveAs Auto Naming Convention.

I've only been able to test in Word 2010, so would appreciate feedback from those of you with other versions (I'm pretty sure it won't work pre 2007, since the way of capturing events is different, but I'm not 100% not sure).  Also, if you have issues in Word 2010, again feedback would be welcome.

Thanks in advance for any feedback, and hope you guys find this useful.

Cheers,

JB

Jul 27, 2011 at 10:19 PM

I had a request to modify the AutoNaming macro (see post above) to use the header text in place of the first line - here's how to alter the code to do that

Insert the below function to pull text from the header section:

Private Function GetHeaderText(ByRef doc As Document) As String
      GetHeaderText = Strings.Replace(doc.Sections.First.Headers(wdHeaderFooterPrimary).Range.Text, "0", " ") '0s are used as column separators; sadly there doesn't seem to be a way to distinguish these from actual 0s
End Function
Then modify the GetSuggestedFilename function to make use of the Header function instead of the FirstLine one, as below:
Private Function GetSuggestedFilename(ByRef doc As Document) As String
      'GetSuggestedFilename = CleanseFilename(GetFirstLine(doc) & SPACER & GetFormattedDate())
      GetSuggestedFilename = CleanseFilename(GetHeaderText(doc) & SPACER & GetFormattedDate())
End Function

Hope that helps,

JB