user11

Hi all,

I was wondering if it's possible to get the word document author programatically the same way as you can get the document name with:
Selection.Document.FullName

Any help much appreciated!
Radu.



Re: Visual Studio Tools for Office Word document author

Phil Hoff - MSFT

Yes, via the BuiltInDocumentProperties property of the Word Document interface (or Document class, in the case of VSTO). See: http://msdn2.microsoft.com/en-us/library/4e0tda25(VS.80).aspx).

Code Snippet

private void ThisDocument_Startup(object sender, System.EventArgs e)

{

MessageBox.Show("Author: " + ((Microsoft.Office.Core.DocumentProperties) BuiltInDocumentProperties)["Author"].Value.ToString());

}

-Phil




Re: Visual Studio Tools for Office Word document author

user11

I'm not sure if this is accessible from a scripting language, is it




Re: Visual Studio Tools for Office Word document author

Phil Hoff - MSFT

Yes. VSTO wraps the property in its own Document class, but it's part of the Word object model.

Code Snippet

Sub DisplayAuthor()
Dim author As String
author = ActiveDocument.BuiltInDocumentProperties(wdPropertyAuthor)
MsgBox "This document was authored by " & author & "."
End Sub

-Phil




Re: Visual Studio Tools for Office Word document author

user11

So I have to use Microsoft.Office.Core, you say
In a script should I use the C:\Program Files\Common Files\Microsoft Shared\OFFICE11\MSO.DLL or the one in GAC C:\WINDOWS\assembly\GAC\office\11.0.0.0__71e9bce111e9429c\OFFICE.DLL

Thanks a million,
Radu.