以下是引用lianyicq在2015-4-14 13:33:07的发言:
测试成功了。
可以把模块中的代码取出并放到指定的textbox中。就是用vbide对象。
你按这思路做下去,有具体问题再说。
测试成功了。
可以把模块中的代码取出并放到指定的textbox中。就是用vbide对象。
你按这思路做下去,有具体问题再说。
非常感谢版主!
能否上传一个实际的示例呢?谢谢!
Public VBInstance As VBIDE.VBE Public Connect As Connect Option Explicit Private Sub CancelButton_Click() Connect.Hide End Sub Private Sub Command1_Click() Dim SourceComponent As VBComponent Dim comp As VBComponent Dim ctrl As VBControl Dim DESTForm As VBForm Dim DESTTextBox As VBControl Set SourceComponent = VBInstance.VBProjects.Item(Text1.Text).VBComponents.Item(Text2.Text) Text3.Text = SourceComponent.CodeModule.Lines(1, SourceComponent.CodeModule.CountOfLines) For Each comp In VBInstance.ActiveVBProject.VBComponents Text3.Text = Text3.Text & vbCrLf & comp.Name If (comp.Type = vbext_ct_VBForm And comp.Name = Text5.Text) Then Set DESTForm = comp.Designer Next For Each ctrl In DESTForm.ContainedVBControls Text3.Text = Text3.Text & vbCrLf & ctrl.Properties("Name").Value & "[" & ctrl.ClassName & "]" If ctrl.Properties("Name").Value = Text4.Text Then ctrl.Properties("Text") = Text3.Text Next End Sub Private Sub Form_Load() End Sub Private Sub OKButton_Click() MsgBox "外接程序操作作用于: " & VBInstance.FullName End SubADDIN窗体如ReadCode窗体