Displaying the contents of file properties in a MsgBox

A

andreas

Dear Experts:

I would like to have a macro that performs the following action:

Show me the contents of the fields 'Author' and 'Title' which can be
accessed thru 'File-Properties-Summary-Author' and 'File-Properties-
Summary-Title'..... in a MsgBox.

If one of the fields has got no entry, the MsgBox is to say so, such
as 'Author': no entry

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
 
D

Doug Robbins - Word MVP

Use the following code:

Dim Title As String, Author As String
With ActiveDocument
Title = .BuiltInDocumentProperties(wdPropertyTitle)
If Title <> "" Then
Title = Title
Else
Title = "No Title"
End If
Author = .BuiltInDocumentProperties(wdPropertyAuthor)
If Author <> "" Then
Author = Author
Else
Author = "No Author"
End If
End With
MsgBox "Document Title: " & Title & vbCr & "Author: " & Author


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
A

andreas-hermle

Use the following code:

Dim Title As String, Author As String
With ActiveDocument
    Title = .BuiltInDocumentProperties(wdPropertyTitle)
    If Title <> "" Then
        Title = Title
    Else
        Title = "No Title"
    End If
    Author = .BuiltInDocumentProperties(wdPropertyAuthor)
    If Author <> "" Then
        Author = Author
    Else
        Author = "No Author"
    End If
End With
MsgBox "Document Title: " & Title & vbCr & "Author: " & Author

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.











- Show quoted text -

Hi Doug,

as always. Thank you very much for your terrific help. I really
appreciate it.

Regards, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top