Created
August 1, 2016 05:22
-
-
Save toagit/4561c2813bccf39aef0e2256822f3905 to your computer and use it in GitHub Desktop.
vbaプロジェクトの全てのモジュールをエクスポートする
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
'全モジュールエクスポート | |
' | |
'Excelの設定を以下の通りに変更すること | |
'1)オプション -> セキュリティーセンター -> [セキュリティーセンターの設定]ボタン押下 | |
'2)マクロ設定(左ペイン) -> [VBAプロジェクトオブジェクトモデルへのアクセスを信頼する] チェックON | |
Public Sub ExportAllModule() | |
Dim destDir As String | |
With CreateObject("WScript.Shell") | |
destDir = .SpecialFolders("Desktop") & "\modules" | |
End With | |
If Dir(destDir, vbDirectory) = "" Then | |
Call MkDir(destDir) | |
End If | |
With ActiveWorkbook.VBProject | |
Const vbext_ct_StdModule As Variant = 1 | |
Const vbext_ct_MSForm As Variant = 2 | |
Const vbext_ct_ClassModule As Variant = 3 | |
Dim ext As String | |
Dim c As Object | |
For Each c In .VBComponents | |
Select Case c.Type | |
Case vbext_ct_StdModule | |
ext = ".bas" | |
Case vbext_ct_MSForm | |
ext = ".frm" | |
Case vbext_ct_ClassModule | |
ext = ".cls" | |
Case Else | |
ext = Empty | |
End Select | |
If ext <> Empty Then | |
Call c.Export(destDir & "\" & c.Name & ext) | |
End If | |
Next | |
End With | |
MsgBox "モジュールのエクスポートを完了しました。" & vbNewLine & destDir | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment