ExecuteLine 方法 (Visio)Document.ExecuteLine method (Visio)

执行一行 Microsoft Visual Basic 代码。Executes a line of Microsoft Visual Basic code.


表达式ExecuteLine()expression.ExecuteLine (Line)

_表达式_一个代表**Document** 对象的变量。expression A variable that represents a Document object.


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
LineLine 必需Required StringString 将被解释为 Microsoft Visual Basic for Applications (VBA) 代码的字符串。A string that will be interpreted as Microsoft Visual Basic for Applications (VBA) code.

返回值Return value



通知 Document 对象的 VBA 项目执行提供的字符串。The VBA project of the Document object is told to execute the supplied string. VBA 将对该字符串进行处理,就像处理在其“立即”窗口中键入的同一个字符串一样。VBA treats the string as it would treat the same string typed into its Immediate window.


以下是 ExecuteLine 方法的一些可能的用途:The following are some possible uses of the ExecuteLine method:

'Executes the macro (procedure without an argument) named "SomeMacro" 
 'that is in some module of the Visual Basic project of ThisDocument. 
 ThisDocument.ExecuteLine("SomeMacro ") 
 'Executes the procedure named SomeProcedure and passes it 3 arguments. 
 ThisDocument.ExecuteLine("SomeProcedure  1, 2, 3") 
 'Same as previous example, but procedure name qualified 
 'with module name. 
 ThisDocument.ExecuteLine("Module1.SomeProcedure  1, 2, 3") 
 'Shows the form UserForm1. 
 'Prints "some string" to the Immediate window. 
 ThisDocument.ExecuteLine("Debug.Print ""some string """) 
 'Prints number of open documents to the Immediate window. 
 ThisDocument.ExecuteLine("Debug.Print Documents.Count") 
 'Tells ThisDocument to save itself. 

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.