title: Change CodePane to Active Module Pane (VBE)
body: <p>I'm programming in the VBA Editor (extensibility) and creating a new module programmatically.  The new module is created without problem.  However, when the new module is created it opens up in the code pane as a blank module, which it is.  However, I want the active module (the one running the code which created the new module) to return to the code pane after the new one is created.  I don't know what the command would be to do that.  This is what I've tried so far.</p>
  
  <pre><code>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
  </code></pre>