从excel vba中调用使用.Run的外部子(在word中)返回数据
由于在Excel VBA例程中运行Word VBA例程,无法解决问题。 我select通过使用Call wdApp.Run(.....
并将值从Excel sub
传递给Word的sub
从字外部运行sub
。
Word中的macrossearch某些短语。 它的工作原理,但现在的问题是如何将search结果传回给Excel Sub
。
Sub
不返回任何东西。 你需要一个Function
。
Public Function GetFoo(ByVal bar As Long) As Long GetFoo = bar * 42 'assign to the function's identifier to set return value End Function
那么你可以得到它的返回值:
Dim result As Long result = wdApp.Run("GetFoo", 10)