js和vba哪个难

JavaScript06

js和vba哪个难,第1张

vba难。建议学javascript如果你会ASP再学vbs可能因为类似稍微简单一点点,但损失实在太多了。js使用数量,书籍,网上代码量都是VBS比不上的。js是客户端脚本的主流趋势,象强大AJAX都是基于JS的。

Word 开发人员参考

Application.Run 方法

运行 Visual Basic 宏。

语法

表达式.Run(MacroName, varg1, varg2, varg3, varg4, varg5, varg6, varg7, varg8, varg9, varg10, varg11, varg12, varg13, varg14, varg15, varg16, varg17, varg18, varg19, varg20, varg21, varg22, varg23, varg24, varg25, varg26, varg27, varg28, varg29, varg30)

表达式 必选。一个代表 Application 对象的变量。

参数

名称 必选/可选 数据类型 说明

MacroName 必选 String 宏的名称。

varg1...varg30 可选 Variant 宏参数值。最多可以给指定宏传递 30 个参数值。

说明

MacroName 参数可以是任意模板、模块和宏名的组合。例如,下列语句均有效。

Visual Basic for Applications

Application.Run "Normal.Module1.MAIN"

Application.Run "MyProject.MyModule.MyProcedure"

Application.Run "'My Document.doc'!ThisModule.ThisProcedure"

如果指定了文档名,则此代码只能运行与当前环境有关的文档中的宏,而不是任何文档中的任何宏。

虽然 Visual Basic 代码可直接调用宏(无需使用 Run 方法),但当宏名存储在变量中时该方法仍很有用。(有关详细信息,请参见本主题示例。)下面三条语句作用相同。前两条语句需要引用 Normal.dot(被调用宏所在的项目);第三条语句由于使用 Run 方法,因此无需引用 Normal.dot 项目。

Visual Basic for Applications

Normal.Module2.Macro1

Call Normal.Module2.Macro1

Application.Run MacroName:="Normal.Module2.Macro1"

示例

本示例提示用户输入模板名、模块名、宏名以及参数值,然后运行该宏。

Visual Basic for Applications

Dim strTemplate As String

Dim strModule As String

Dim strMacro As String

Dim strParameter As String

strTemplate = InputBox("Enter the template name")

strModule = InputBox("Enter the module name")

strMacro = InputBox("Enter the macro name")

strParameter = InputBox("Enter a parameter value")

Application.Run MacroName:=strTemplate &"." _

&strModule &"." &strMacro, _

varg1:=strParameter