Consulting

Results 1 to 6 of 6

Thread: Solved: Word Properties

  1. #1
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location

    Question Solved: Word Properties

    Hello ,

    I would like to know how can I display the followings:

    1. Author
    2. Last Saved By
    3. Application Name
    4. Company
    5. Date Created
    6. Data Last Saved
    7. Edit Time
    8. Revision Number

    9. Title
    10. Subject
    11. Category
    12. Keywords
    13. Template
    14. Pages
    15. Word Count
    16. Character Count
    17. Line Count
    18. Paragraph Count

    All above needed to be displayed at the last page (page break automatically) of the document.

    I know these data can be accessed through right click the word docment and select properties, but I do not want to go through a these steps. I just want it to display at last page of word.

    If cannot display in last page, can we display in a floating form or toolbar and still use Word application?

    Is it possible?


    Thanks.

  2. #2
    VBAX Mentor Marcster's Avatar
    Joined
    Jun 2005
    Posts
    434
    Location

    Smile Word Properties

    Hi sheeeng ,

    Hope the follow puts you in the right direction:

    Goto the Visual Basic Editor. Tools > Macros > Visual Basic Editor
    or
    press Alt+F11
    Then Help > Microsoft Visual Basic Help
    or
    press F1
    In The Type keywords text box on the left type:
    BuiltinDocumentProperty
    Click on Search (this will give an example of a macro to use)

    -----

    You can also insert a word field by,

    Insert > Field...
    Select Document Information under Categories
    Select what type of info you want under Field names
    Click OK.

    Hope that helps

  3. #3
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    These are part of the DocumentProperties collection - the Built in ones - so you can get to them easily enough.[VBA]Sub DisplayDocProperties()

    Dim dp As DocumentProperty
    Dim tempstring As String

    For Each dp In ActiveDocument.BuiltInDocumentProperties
    On Error Resume Next 'reading uninitialized value causes an error
    tempstring = tempstring & dp.Name & ": " & dp.Value & vbLf
    Next
    MsgBox tempstring

    End Sub[/VBA] You just need to decide which ones you want, format the output and place it where ever... (at the end of the document, as labels on a modeless form or captions on a toolbar), here's a quick snippent that punts it at the end of the doc[VBA]Dim rng As Range

    Set rng = ActiveDocument.Range
    rng.Collapse wdCollapseEnd

    rng.InsertBreak (wdPageBreak)
    rng.Text = tempstring[/VBA]
    K :-)

  4. #4
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    You could also insert a field directly into the document which contains the required information. Just have a look at the InsertField-Dialog and select Document Information in the left list.

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi,

    Another method would be to use the Dialog wdDialogDocumentStatistics to retrieve and perhaps show the data.

    Like:[VBA]
    Sub DocStats()
    Dim oDlg As Word.Dialog
    Set oDlg = Application.Dialogs(wdDialogDocumentStatistics)
    oDlg.Show
    MsgBox oDlg.LastSaved

    Set oDlg = Nothing

    End Sub
    [/VBA]

    Later..
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  6. #6
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    [VBA]Sub DisplayDocProperties()

    Dim dp As DocumentProperty
    Dim tempstring As String

    For Each dp In ActiveDocument.BuiltInDocumentProperties
    On Error Resume Next 'reading uninitialized value causes an error
    tempstring = tempstring & dp.Name & ": " & dp.Value & vbLf
    Next

    'To MsgBox
    MsgBox tempstring


    'To Document
    Dim rng As Range

    Set rng = ActiveDocument.Range
    rng.Collapse wdCollapseEnd

    rng.InsertBreak (wdPageBreak)
    rng.Text = tempstring
    End Sub[/VBA] Thx All.

    I prefer this code by Killian, which solved my needs.
    Another marked solved.
    Thx again.

Posting Permissions

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