Search code examples
vbaword-2010custom-properties

Print a Custom doc property


Here is my current code.

Sub PrintMasterTime()

Dim PropVal As Integer
    PropVal = ActiveDocument.CustomDocumentProperties(MasterTime).Value
    Print PropVal

End Sub

Compile Error: Method not valid without suitable object

Not sure why it's not printing. "MasterTime" is the name of my custom document property.


Solution

  • You need to call CustomDocumentProperties with a string. You forgot the quotes.

    PropVal = ActiveDocument.CustomDocumentProperties("MasterTime").Value