Click to See Complete Forum and Search --> : Problem when using Option Explicit ON


gibea00
January 30th, 2003, 09:37 AM
Hi

I want to open a word document using vb net. All works find when i'm not usins Option Explicit on and
Option Strict On.

here's my code

Dim objwrd As Object

objwrd = CreateObject("Word.application")
objwrd.application.Visible = True
objwrd.Documents.open("E:\VbNet\test.doc")

The last two lines are in error if these two option are ON . Why? Is anyboby can help me with this?

Thank you

DSJ
January 30th, 2003, 09:42 AM
Option Strict means you HAVE to define every variable as a specific date type (or object) so this should work

Dim objWord as Word.Application 'Specific Object Type

INSTEAD of

Dim objWord as Object ' Generic Object