tags:

views:

1244

answers:

2
+4  A: 

I can think of 2 ways to do this:

I would go with the second option if you can, because that way you don't have to depend on Word being installed on the system.

amdfan
+5  A: 

Microsoft provides a very useful little assembly called DSOFile. With a reference to it in your project, you can modify Office document properties. It won't necessarily let you open the actual Office file's properties dialog, but you could certainly simulate it.

According to Microsoft:

The Dsofile.dll files lets you edit Office document properties when you do not have Office installed

More details and a download link can be found at http://support.microsoft.com/kb/224351

Here's a snippet some (very old) VB code I used ages ago. Sorry I haven't converted to C# and be aware that it's part of a class so there are references to instance variables. Still, it should be pretty easy to understand and covert to your own needs:

Private Sub ProcessOfficeDocument(ByVal fileName As String)
 Dim docDSO As New DSOFile.OleDocumentPropertiesClass
 Dim docTitle, docModified, docAuthor, docKeywords As String
 Try
  docDSO.Open(fileName, True)
  Dim docSummary As DSOFile.SummaryProperties = docDSO.SummaryProperties
  docTitle = docSummary.Title
  docAuthor = docSummary.Author
  docKeywords = docSummary.Keywords
  docModified = CStr(docSummary.DateLastSaved)

  If (Not String.IsNullOrEmpty(docTitle)) Then
   _Title = docTitle
  End If

  If (Not String.IsNullOrEmpty(docAuthor)) Then
   _Author = docAuthor
  End If

  If (Not String.IsNullOrEmpty(docModified)) Then
   _DateModified = DateTime.Parse(docModified)
  End If

 Catch ex As Exception
  'Do whatever you need to do here...'
 Finally
  If (Not docDSO Is Nothing) Then
   docDSO.Close()
  End If
 End Try
End Sub
AR
I'd +5 this if I could.. Great answer.
torial