0
私はVBAエディタ(拡張性)でプログラミングし、プログラムで新しいモジュールを作成しています。新しいモジュールは問題なく作成されます。しかし、新しいモジュールが作成されると、それはブランクモジュールとしてコードペインに表示されます。しかし、新しいモジュールが作成された後、アクティブなモジュール(新しいモジュールを作成したコードを実行しているモジュール)をコードペインに戻したい。私はその命令が何をするのか分からない。これはこれまで私が試したことです。CodePaneをアクティブモジュールペイン(VBE)に変更
Sub addNewStandardModule()
On Error Resume Next' Adds Extensibility Reference for programming in the VBE
ThisWorkbook.VBProject.References.AddFromGuid GUID:="{0002E157-0000-0000-C000-000000000046}", Major:=5, Minor:=3
On Error GoTo 0
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Set VBProj = ActiveWorkbook.VBProject
Set VBComp = VBProj.VBComponents.Add(vbext_ct_StdModule)
VBComp.name = "Module6"
' This is my attempt to return the active module to the active codepane, but it doesn't work
With Application.VBE
If Not .ActiveCodePane Is Nothing Then
Set .ActiveVBProject = .ActiveCodePane.CodeModule.Parent.Collection.Parent
End If
End With
End Sub