PDA

View Full Version : Solved: Word Properties



sheeeng
06-28-2005, 12:35 AM
Hello :hi: ,

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. :help

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? :doh:

Is it possible?


Thanks. :friends:

Marcster
06-28-2005, 03:13 AM
Hi sheeeng :hi: ,

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 :cool:

Killian
06-28-2005, 03:36 AM
These are part of the DocumentProperties collection - the Built in ones - so you can get to them easily enough.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 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 docDim rng As Range

Set rng = ActiveDocument.Range
rng.Collapse wdCollapseEnd

rng.InsertBreak (wdPageBreak)
rng.Text = tempstring

Steiner
06-28-2005, 04:45 AM
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.

MOS MASTER
06-28-2005, 09:15 AM
Hi, :yes

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

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

Set oDlg = Nothing

End Sub


Later..:whistle:

sheeeng
06-28-2005, 09:46 AM
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 Thx All. :hi:

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