Results 1 to 1 of 1

Thread: [FAQ's: OD] How do I read/write a document's BuiltIn properties?

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    [FAQ's: OD] How do I read/write a document's BuiltIn properties?

    The Properties dialog items can be viewed from the menu - "File > Properties > Summary tab" as displayed in Fig. 1 below.


    These are the constanst for the available builtin document properties. If you are doing late binding then you can find the constant values in Word Object Browser.
    • wdPropertyAppName
    • wdPropertyAuthor
    • wdPropertyBytes
    • wdPropertyCategory
    • wdPropertyCharacters
    • wdPropertyCharsWSpaces
    • wdPropertyComments
    • wdPropertyCompany
    • wdPropertyFormat
    • wdPropertyHiddenSlides
    • wdPropertyHyperlinkBase
    • wdPropertyKeywords
    • wdPropertyLastAuthor
    • wdPropertyLines
    • wdPropertyManager
    • wdPropertyMMClips
    • wdPropertyNotes
    • wdPropertyPages
    • wdPropertyParas
    • wdPropertyRevision
    • wdPropertySecurity
    • wdPropertySlides
    • wdPropertySubject
    • wdPropertyTemplate
    • wdPropertyTimeCreated
    • wdPropertyTimeLastPrinted
    • wdPropertyTimeLastSaved
    • wdPropertyTitle
    • wdPropertyVBATotalEdit
    • wdPropertyWords



    Word 2003 VBA Code Example:

    VB Code:
    1. 'READ PROPERTIES
    2. Option Explicit
    3.  
    4. Private Sub cmdReadProps_Click()
    5.  
    6.     Dim iLines As Integer
    7.     iLines = ActiveDocument.BuiltInDocumentProperties(wdPropertyLines)
    8.     MsgBox "There are " & iLines & " lines in the current document.", vbOkOnly + vbInformation
    9.  
    10.     Dim lWords As Long
    11.     lWords = ActiveDocument.BuiltInDocumentProperties(wdPropertyWords)
    12.     MsgBox "There are " & lWords & " words in the current document.", vbOkOnly
    13.  
    14.     Dim sWhen As String
    15.     sWhen = ActiveDocument.BuiltInDocumentproperties(wdPropertyTimeLastSaved)
    16.     MsgBox "The last time the current document was saved was " & sWhen, vbOkOnly
    17.  
    18.     Dim sPrinted As String
    19.     sPrinted = ActiveDocument.BuiltInDocumentProperties(wdPropertyTimeLastPrinted)
    20.     MsgBox "The last time the current document was printed was " & sPrinted, vbOkOnly
    21.  
    22. End Sub

    VB Code:
    1. 'WRITE PROPERTIES
    2. Option Explicit
    3.  
    4. Private Sub cmdWriteProps_Click()
    5.  
    6.     ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle) = "How do I read/write a document's BuiltIn properties?"
    7.    
    8.     ActiveDocument.BuiltInDocumentProperties(wdPropertySubject) = "[FAQ's: OD] Word"
    9.    
    10.     ActiveDocument.BuiltInDocumentProperties(wdPropertyCompany) = "VB/Office Guru™"
    11.    
    12.     ActiveDocument.BuiltInDocumentProperties(wdPropertyCategory) = "Office Development - Word"
    13.    
    14.     ActiveDocument.BuiltInDocumentProperties(wdPropertyComments) = "This is a FAQ code example of manipulating Words BuiltIn document properties."
    15.    
    16.     ActiveDocument.BuiltInDocumentProperties(wdPropertyHyperlinkBase) = "http://vbforums.com/forumdisplay.php?f=37"
    17.  
    18. End Sub

    Fig. 1
    Last edited by RobDog888; Jun 18th, 2006 at 01:01 PM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width