0

I'm trying to call this code in VB.NET with "option strict on":

Dim application As word.Application = New word.Application
application.WordBasic.DisableAutoMacros(1)

The WordBasic object is dynamic, there is no type library available.
Now the compiler will complain, because late binding is not allowed.

Is there a workaround?

4

1 回答 1

1

是的,自 VS2008 以来,这在 vb.net 中被破坏了,这是 Linq 和 Option Infer 强国的受害者。

使其早期绑定太棘手了,有太多版本的 VBA 浮动。值得注意的是,我无法让反射工作,这通常是进行后期绑定的早期绑定方式:) 最好的办法是将此代码放在单独的源代码文件中,这样您就可以使用 Option Strict Off 进行编译.

于 2012-05-09T13:44:09.047 回答