Setting DocumentProperties in Word 2007 using vb.Net ASPX Page

K

kennymce

Hi All,

I'm having trouble updating the DocumentProperties in Word 2007. I'm trying
to use an ASPX page writte in VB.NET update the 'Subject' property in a
document. All the methods I've seen suggest something like this:

Dim oWord As New Word.Application
Dim oDoc As Microsoft.Office.Interop.Word.Document
Dim properties As Microsoft.Office.Core.DocumentProperties

oDoc = oWord.Documents.Open("C:\Templates\Saves\Time Table.DOC")
properties = DirectCast(oDoc.BuiltInDocumentProperties, _
Microsoft.Office.Core.DocumentProperties)
properties.Item("Subject").Value = "Test"

However, I get the following error on the DirectCast line:


Unable to cast COM object of type 'System.__ComObject' to interface type
'Microsoft.Office.Core.DocumentProperties'. This ope
ration failed because the QueryInterface call on the COM component for the
interface with IID '{2DF8D04D-5BFA-101B-BDE5-00AA0
044DE52}' failed due to the following error: No such interface supported
(Exception from HRESULT: 0x80004002 (E_NOINTERFACE))

Can anyone suggest an article or a solution to this problem?



Thanks in advance,
Kenny
 
C

Cindy M.

Hi Kenny,
I'm having trouble updating the DocumentProperties in Word 2007. I'm trying
to use an ASPX page writte in VB.NET update the 'Subject' property in a
document
Have you seen this KB article
http://support.microsoft.com/kb/303294

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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