Document.ExecuteLine 方法 (Visio)

會執行一行 Microsoft Visual Basic 程式碼。

語法

運算式ExecuteLine ()

表達 代表 Document 物件的變數。

參數

名稱 必要/選用 資料類型 描述
Line 必要 字串 要解譯為 Microsoft Visual Basic for Applications (VBA) 程式碼的字串

傳回值

註解

系統會告訴 Document 物件的 VBA 專案執行提供的字串。 VBA 會將字串當做在 [即時運算] 視窗中輸入一樣的處理。

範例

以下是 ExecuteLine 方法的一些可能用法:

'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. 
 ThisDocument.ExecuteLine("UserForm1.Show") 
 
 '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. 
 ThisDocument.ExecuteLine("ThisDocument.Save") 

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應