Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Document.ExecuteLine Method

Office 2007
Executes a line of Microsoft Visual Basic code.

Version Information
 Version Added:  Visio 4.5

Syntax

expression.ExecuteLine(Line)

expression   A variable that represents a Document object.

Parameters

NameRequired/OptionalData TypeDescription
LineRequiredStringA string that will be interpreted as Microsoft Visual Basic for Applications (VBA) code.

Return Value
Nothing

Remarks

The VBA project of the Document object is told to execute the supplied string. VBA treats the string as it would treat the same string typed into its Immediate window.

Example

The following are some possible uses of the ExecuteLine method:

Visual Basic for Applications

    '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")



Community Additions

ADD
Show:
© 2015 Microsoft