| < Free Open Study > |
|
The AddMethodToEndOfDocument method shown in the following code uses the TextDocument and EditPoint objects to place a new method at the end of the module in the active window. The module can be a class, module, or code for a form. Cursor position is of no consequence.
Public Sub AddMethodToEndOfDocument(ByVal NewMethod As String) Dim objTD As TextDocument = oVB.ActiveDocument.Object Dim objEP As EditPoint = objTD.EndPoint.CreateEditPoint ' We are past the end of the last line of the document ' move back in front of the End Module/Class objEP.LineUp(1) ' if a c# file, we must get within the namespace and ' the class braces If Me.GetFileType(oVB.ActiveDocument) = 9 Then objEP.LineUp(1) End If objEP.Insert(NewMethod) End Sub
| < Free Open Study > |
|