| < Free Open Study > |
|
The PutCodeBack method shown in the following code will replace a selected block of code in a module. It uses only the TextSelection object. You can find this code in the Utilities class in the code for Chapter 12.
Public Sub PutCodeBack(ByVal s As String) Dim selCodeBlock As TextSelection 'Dim datobj As New System.Windows.Forms.DataObject() Try selCodeBlock = CType(oVB.ActiveDocument.Selection(), _ EnvDTE.TextSelection) 'datobj.SetData(System.Windows.Forms.DataFormats.Text, s) 'System.Windows.Forms.Clipboard.SetDataObject(datobj) 'selCodeBlock.Paste() selCodeBlock.Delete() selCodeBlock.Insert(s, 1) Catch e As System.Exception MsgBox("Could not put code back in window.", _ MsgBoxStyle.Critical, _ "PutCodeBackInWindow") End Try End Sub
| < Free Open Study > |
|