user2423014
user2423014

Reputation:

MS Word Object Reference issue

what object reference do I need to make this function work .

Dim oDoc As Word.Application =

I have already selected Microsoft Word 12.0 Object Library

but i still get this error

enter image description here

this function simply finds and opens the Ms Word.exe then takes a file and adds it to the Ms Word file .

I'm sure that i'm missing an object reference but i don't not know which it is .

Upvotes: 0

Views: 846

Answers (1)

Chris
Chris

Reputation: 8647

No missing reference. But you are trying to cast a Word.Document to Word.Application with oDoc, the cast is not valid.

It should be

Dim oDoc As Word.Document = oWord.Documents.Add()

Instead of

Dim oDoc As Word.Application = oWord.Documents.Add()

Upvotes: 1

Related Questions