Thread: [Solved] FILLIN function
View Single Post
 
Old 10-14-2011, 05:06 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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 Skarab,

You could do it with a macro, but not with field coding alone. And, if you're going to use a macro, I'd suggest using a custom document property with code like:
Code:
Private Sub Document_Open()
Dim MyProp As String, StrOld As String, StrNew As String
Restart:
With ThisDocument
  MyProp = "Property_Name"
  StrOld = .CustomDocumentProperties(MyProp).Value
  StrNew = InputBox("What is the variable?", "Update " & MyProp, StrOld)
  If StrNew = "" Then
    MsgBox "A valid string is required.", vbCritical, "Update " & MyProp
    GoTo Restart
  End If
  .CustomDocumentProperties(MyProp).Value = StrNew
  .Fields.Update
End With
End Sub
where 'Property_Name' is your custom property's name. You can then use DOCPROPERTY fields throughout the document to point to that custom property and retrieve its contents. Do note that, if the user disables the macro when the document is opened, the update process won't occur.

An alternative is to use an ASK field (preferably in the header or footer where it's less likely to be deleted by accident) to populate a bookmark and configure Word to update fields at print time. Then simply use cross-references to the ASK field's bookmark name. No code is required for this but it does depend on how each user has Word configured and the prompt will even then only occur when the document is printed.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote