i am trying to adapt the below code for Word 2007. i have tried the
following but to no success.
changed the .doc to .docx (office 2007 standard for saving) but when i run
the macro, i get an error and the fname line is highlighted yellow, when i go
to the line, it shows fname=""
i changed the .FormFields to .Bookmarks, then i get an erro also, but the
.Result is highlighted.
i have reviewed other sources, but the macro that is listed here is more or
less what i am looking for - simple.
any other suggestions on this is appreciated.
jat
The macro works with Word 2007, assuming of course that there is content in
the UserID (legacy field) text field. The following will error trap no
content:
Sub SaveForm()
Dim fName As String
On Error GoTo Noname
With ActiveDocument
fName = .FormFields("UserID").Result & ".docx"
.SaveAs fName, FileFormat:=wdFormatDocumentDefault
End With
Exit Sub
Noname:
MsgBox "UserID field is empty"
End Sub
If you want to use the content of a bookmark then
Sub SaveForm()
Dim fName As String
On Error GoTo Noname
With ActiveDocument
fName = .Bookmarks("UserID").Range.Text & ".docx"
.SaveAs fName, FileFormat:=wdFormatDocumentDefault
End With
Exit Sub
Noname:
MsgBox "UserID bookmark is empty"
End Sub
or you could use the built-in document properties
Sub SaveForm()
Dim fName As String
On Error GoTo Noname
With ActiveDocument
fName = ActiveDocument.BuiltInDocumentProperties("Author") & ".docx"
.SaveAs fName, FileFormat:=wdFormatDocumentDefault
End With
Exit Sub
Noname:
MsgBox "Author field is empty"
End Sub

Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> i am trying to adapt the below code for Word 2007. i have tried the
> following but to no success.
[quoted text clipped - 45 lines]
>>>
>>> AW
jatman - 14 May 2008 18:08 GMT
the first two did not work (form fields and bookmarks,) probably on how i am
setting up the fields or something. so i tried the last one using the built
in document properties thinking it would not work that way i was hoping, and
it worked like a charm. from here, it should be a breeze.
thank you!
> The macro works with Word 2007, assuming of course that there is content in
> the UserID (legacy field) text field. The following will error trap no
[quoted text clipped - 89 lines]
> >>>
> >>> AW
jatman - 15 May 2008 06:59 GMT
thought i was doing well, but one more question.
how do i join two built in document properties? i am using the Publish Date
and Title. i tried the following:
With ActiveDocument
fName = activedocument.builtindocumentproperties("Publish Date")
fName = fname & " " & ActiveDocument.BuiltInDocumentProperties("Title")
& ".docx"
.SaveAs fName, FileFormat:=wdFormatDocumentDefault
i am not sure, but i think it has to do with the date. when i use the Title
alone, it worked. i added the date line to it and now i'm stuck. so i tried
the publish date alone and i get the "empty field error"
the Publish Date uses the date picker, properties display it as dddd,
mmmm-dd-yyyy, and it stores XML contents as Text (same as display.) i tried
the store as date also and no luck.
i really do not care as to how it shows, but the file should save as
"yyyy-mm-dd title of document"
thank you for your assistance so far!
jat
> The macro works with Word 2007, assuming of course that there is content in
> the UserID (legacy field) text field. The following will error trap no
[quoted text clipped - 89 lines]
> >>>
> >>> AW
Graham Mayor - 15 May 2008 08:10 GMT
There is no 'built-in document property' called "Publish Date"
You could use the current date eg
With ActiveDocument
fName = Format(Date, "d" & _
Chr(32) & "MMMM" & Chr(32) & "yyyy") & _
.BuiltInDocumentProperties("Title") & ".docx"
.SaveAs fName, FileFormat:=wdFormatDocumentDefault
End With
or you could create and use a custom document property called Publish Date
then
With ActiveDocument
fName = .CustomDocumentProperties("Publish Date") & _
.BuiltInDocumentProperties("Title") & ".docx"
.SaveAs fName, FileFormat:=wdFormatDocumentDefault
End With

Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> thought i was doing well, but one more question.
>
[quoted text clipped - 125 lines]
>>>>>
>>>>> AW