View Single Post
 
Old 04-21-2011, 10:22 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi KJJ,

Much of your code isn't related to the task you've described, so I've omitted it from the code below. Also, instead of using an 'Document_Close' macro, I've used a 'AutoClose' macro, which you place in the template's 'ThisDocument' module. The code below provides the prompts you're after, and only updates the properties if anything's changed. That way, the document doesn't give unnecessary 'save' prompts (though if you do include your other code for updating fields, you're going to get 'save' prompts anyway).
Code:
Private Sub Document_Close()
Dim StrOldTitle As String, StrNewTitle As String
Dim StrOldAuthor As String, StrNewAuthor As String
Dim StrOldSubject As String, StrNewSubject As String
Dim bSaved As Boolean
With ActiveDocument
  bSaved = .Saved
  StrOldTitle = .BuiltInDocumentProperties("Title").Value
  StrOldAuthor = .BuiltInDocumentProperties("Author").Value
  StrOldSubject = .BuiltInDocumentProperties("Subject").Value
  StrNewTitle = InputBox("Enter the Document Title:", "Title", StrOldTitle)
  StrNewAuthor = InputBox("Enter the Document Author:", "Author", StrOldAuthor)
  StrNewSubject = InputBox("Enter the Client and Site Name:", "Subject", StrOldSubject)
  If StrOldTitle <> StrNewTitle Then _
    .BuiltInDocumentProperties("Title").Value = StrNewTitle
  If StrOldAuthor <> StrOldAuthor Then _
    .BuiltInDocumentProperties("Author").Value = StrNewAuthor
  If StrOldSubject <> StrOldSubject Then _
    .BuiltInDocumentProperties("Subject").Value = StrNewSubject
  If bSaved = True And .Saved = True Then Exit Sub
End With
End Sub
PS: When posting code, please format it and use Code tags.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote