ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] Macro List

[µo°Ý] Macro List

¤j¤j¦n,

ÀHµÛ¨Ï¥ÎVBAªº¶q¼W¥[«á,¦³®É­n§äµ{¦¡ªº©Ò¦b,­nªá¦n¤@·|¨à¥\¤Ò,
¥B¦P¤@­ÓModule·|¦³¦h­ÓSub ¦WºÙ
·Q½Ð°Ý¯à§_±N¼Ò²Õ¤¤ªº©Ò¦³Module & Sub ¦WºÙ
¨Ì§Ç±NModule1.Sub ¦WºÙ
Module2.Sub ¦WºÙ ....
§â¥¦¥þ³¡List ¦bTXT or excel¤¤ ? ¤è«K¬d§äµ{¦¡?

¦^´_ 4# ­ã´£³¡ªL
¦^´_ 3# quickfixer
¤G¦ì¦n,
§Ú§âµ{¦¡§ì¤U¨Ó·Q´ú¸Õ,¦ý¥d¦í¤F,¥i¥HÀ°§Ú¬Ý¬Ý¶Ü?
20200417.223301.jpg
  1. Sub Command1_Click()
  2.     ' Declare variables to access the Excel workbook.
  3.     Dim objXLApp As Excel.Application
  4.     Dim objXLWorkbooks As Excel.Workbooks
  5.     Dim objXLABC As Excel.Workbook

  6.     ' Declare variables to access the macros in the workbook.
  7.     Dim objProject As VBIDE.VBProject
  8.     Dim objComponent As VBIDE.VBComponent
  9.     Dim objCode As VBIDE.CodeModule

  10.     ' Declare other miscellaneous variables.
  11.     Dim iLine As Integer
  12.     Dim sProcName As String
  13.     Dim pk As vbext_ProcKind

  14.     ' Open Excel, and open the workbook.
  15.     Set objXLApp = New Excel.Application
  16.     Set objXLWorkbooks = objXLApp.Workbooks   
  17.     Set objXLABC = objXLWorkbooks.Open("C:\ABC.XLS")

  18.     ' Empty the list box.
  19.     List1.Clear

  20.     ' Get the project details in the workbook.
  21.     Set objProject = objXLABC.VBProject

  22.     ' Iterate through each component in the project.
  23.     For Each objComponent In objProject.VBComponents

  24.         ' Find the code module for the project.
  25.         Set objCode = objComponent.CodeModule

  26.         ' Scan through the code module, looking for procedures.
  27.         iLine = 1
  28.         Do While iLine < objCode.CountOfLines
  29.             sProcName = objCode.ProcOfLine(iLine, pk)
  30.             If sProcName <> "" Then
  31.                 ' Found a procedure. Display its details, and then skip
  32.                 ' to the end of the procedure.
  33.                 List1.AddItem objComponent.Name & vbTab & sProcName
  34.                 iLine = iLine + objCode.ProcCountLines(sProcName, pk)
  35.             Else
  36.                 ' This line has no procedure, so go to the next line.
  37.                 iLine = iLine + 1
  38.             End If
  39.         Loop
  40.         Set objCode = Nothing
  41.         Set objComponent = Nothing
  42.     Next

  43.     Set objProject = Nothing

  44.     ' Clean up and exit.
  45.     objXLABC.Close
  46.     objXLApp.Quit
  47. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¤Hªº§Ö¼Ö¡D¤£¬O¦]¬°¥L¾Ö¦³±o¦h¡A¦Ó¬O¦]¬°¥L­p¸û±o¤Ö¡C
ªð¦^¦Cªí ¤W¤@¥DÃD