2017-11-07 5 views

答えて

1

はい。

はこちらをご覧ください - このような http://www.cpearson.com/excel/vbe.aspx

何かが作業の一部を行います。

Sub ListProcedures() 
    Dim VBProj As VBIDE.VBProject 
    Dim VBComp As VBIDE.VBComponent 
    Dim CodeMod As VBIDE.CodeModule 
    Dim LineNum As Long 
    Dim NumLines As Long 
    Dim WS As Worksheet 
    Dim Rng As Range 
    Dim ProcName As String 
    Dim ProcKind As VBIDE.vbext_ProcKind 

    Set VBProj = ActiveWorkbook.VBProject 
    Set VBComp = VBProj.VBComponents("Module1") 
    Set CodeMod = VBComp.CodeModule 

    Set WS = ActiveWorkbook.Worksheets("Sheet1") 
    Set Rng = WS.Range("A1") 
    With CodeMod 
     LineNum = .CountOfDeclarationLines + 1 
     Do Until LineNum >= .CountOfLines 
      ProcName = .ProcOfLine(LineNum, ProcKind) 
      Rng.Value = ProcName 
      Rng(1, 2).Value = ProcKindString(ProcKind) 
      LineNum = .ProcStartLine(ProcName, ProcKind) + _ 
        .ProcCountLines(ProcName, ProcKind) + 1 
      Set Rng = Rng(2, 1) 
     Loop 
    End With 

End Sub 
関連する問題