Created
June 2, 2023 12:57
-
-
Save gekka/4e4e52f20e0915184a6b7d536826f12e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub ExportTest() | |
Dim ads As Excel.AddIns | |
Set ads = Application.AddIns | |
Dim iAd As Integer | |
Dim iPrj As Integer | |
For iAd = 1 To ads.Count | |
Dim ad As Excel.AddIn | |
Set ad = ads.Item(iAd) | |
For iPrj = 1 To Application.VBE.VBProjects.Count | |
Dim p As VBIDE.VBProject | |
Set p = Application.VBE.VBProjects(iPrj) | |
Dim prjFilename As String | |
On Error Resume Next | |
prjFilename = p.Filename | |
On Error GoTo 0 | |
If (prjFilename = ad.FullName) Then | |
Dim cmp As VBIDE.VBComponent | |
Dim iCmp As Integer | |
On Error Resume Next | |
iCmp = p.VBComponents.Count | |
If Err.Number = 50289 Then | |
Debug.Print ad.Name & "はプロテクトされてます" | |
Exit For | |
ElseIf Err.Number <> 0 Then | |
Debug.Print cmp.Name & " " & Err.Description | |
Exit For | |
End If | |
On Error GoTo 0 | |
For Each cmp In p.VBComponents | |
Debug.Print p.Name, cmp.Name | |
Dim targetFolder As String | |
targetFolder = "D:\Temp\Export\" & p.Name | |
Dim parts | |
parts = Split(targetFolder, "\") | |
Dim temp As String | |
temp = "" | |
For i = LBound(parts) To UBound(parts) | |
temp = temp & parts(i) & "\" | |
If Dir(temp, vbDirectory) = "" Then | |
Call MkDir(temp) | |
End If | |
Next | |
Call cmp.Export(targetFolder & "\" + cmp.Name) | |
Next | |
End If | |
Next | |
Next | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment