View Single Post
 
Old 01-20-2014, 05:56 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Yeah basically,

The properties listed as custom properties don't really exist until you use the name and assign a value:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oCP As DocumentProperty
  With ActiveDocument
    On Error Resume Next
    Set oCP = .CustomDocumentProperties("Office")
    If Not Err.Number = 0 Then
      Set oCP = .CustomDocumentProperties.Add(Name:="Office", LinkToContent:=False, Value:=InputBox("What is your Office location?", "Home Base"), Type:=msoPropertyTypeString)
    Else
      oCP.Value = InputBox("What is your Office location?", "Home Base")
    End If
    On Error GoTo 0
    Debug.Print oCP.Value
  End With
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote