ParseLine method

Microsoft Visio Developer Reference

ParseLine method

   Example   

Parses a line of Microsoft Visual Basic code.

Version added

4.5

Syntax

object.ParseLine line

object

Required. An expression that returns a Document object.

line

Required String. A string interpreted as Visual Basic for Applications (VBA) code.

Remarks

The ParseLine method tells the VBA project of the Document object to parse the string. VBA treats the string like it would treat the same string typed into its Immediate window.

The ParseLine method creates a Visual Basic project in the document if one does not exist. The ParseLine method raises an exception if the string fails to parse. You can determine whether the string has successfully parsed using the following technique.

Public Sub parse(str As String)
    On Error Resume Next
    ThisDocument.ParseLine str
    If Err = 0 Then
        MsgBox "String parsed successfully"
    Else
        MsgBox "Parse not successful" 
    End If
End Sub