G
Guest
Hi
first of all, sorry for my bad english
anyway, i am trying to access a word document in c# but my code doesnt work!
i have search through the net about Office Automation and i have found man
articles and forums speaking about it but no answer to my prob
IMPORTANT: I am using
- W2K
- Word2000
- Visual studio .Net 200
- Microsoft Office 9.0 Object Librar
- Microsoft Word 9.0 Object Librar
my code is
object oMissing = System.Reflection.Missing.Value
Word.ApplicationClass oWord
Word.Document oDoc
oWord = new Word.ApplicationClass()
oWord.Visible = true
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing
ref oMissing, ref Missing)
..... etc ..
At runtime i got the following error
An unhandled exception of type 'System.InvalidCastException' occurred i
WindowsApplication2.ex
Additional information: QueryInterface for interface Word._Applicatio
failed
The problem is that 'new Word.ApplicationClass();' is not able to inizialize the variable 'oWord' and I dont know why
Microsoft Office 9.0 Object Library, Microsoft Word 9.0 Object Library should be the right ones for Word2000
I know there are new Pias for Word2002 or 2003, but i need to open, create etc. a Word2000 document
Any idea
Thank
federic
first of all, sorry for my bad english
anyway, i am trying to access a word document in c# but my code doesnt work!
i have search through the net about Office Automation and i have found man
articles and forums speaking about it but no answer to my prob
IMPORTANT: I am using
- W2K
- Word2000
- Visual studio .Net 200
- Microsoft Office 9.0 Object Librar
- Microsoft Word 9.0 Object Librar
my code is
object oMissing = System.Reflection.Missing.Value
Word.ApplicationClass oWord
Word.Document oDoc
oWord = new Word.ApplicationClass()
oWord.Visible = true
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing
ref oMissing, ref Missing)
..... etc ..
At runtime i got the following error
An unhandled exception of type 'System.InvalidCastException' occurred i
WindowsApplication2.ex
Additional information: QueryInterface for interface Word._Applicatio
failed
The problem is that 'new Word.ApplicationClass();' is not able to inizialize the variable 'oWord' and I dont know why
Microsoft Office 9.0 Object Library, Microsoft Word 9.0 Object Library should be the right ones for Word2000
I know there are new Pias for Word2002 or 2003, but i need to open, create etc. a Word2000 document
Any idea
Thank
federic