I was asked to produce a feature that replaces the author and last modified/saved by document properties of any Word document.
The former is easy enough, and for the latter i figured I could simply change the Office user name, save the file and then restore the user name to its original state.
The below code seems to work just fine for me, but when I tested it on other computers the author was changed but not the last modified by.
Does anyone have any idea why this is? Grateful for any pointers/suggestions on how to sort out the code or reach the same result in another way!
Sub ChangeAuthor()
Dim Author As String
Dim orig As String
Dim Doc As Document
Author = InputBox("Enter the new document author name.")
orig = Application.UserName
With Dialogs(wdDialogFileOpen)
If .Display Then
If .Name <> "" Then
Set Doc = Documents.Open(.Name)
End If
Else
MsgBox "No file selected"
End If
End With
Application.UserName = Author
With Doc
.BuiltInDocumentProperties("Author") = Author
.Saved = False
.Save
.Close
End With
Application.UserName = orig
MsgBox ("Done!")
End Sub