Last active
December 27, 2022 08:00
-
-
Save m5knt/b63ec4f24b195e3d6ebd1475e586c46b to your computer and use it in GitHub Desktop.
Import vba module
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
' 動作させる為には | |
' ファイル => オプション => セキュリティーセンター => セキュリティーセンターの設定 | |
' マクロの設定 => "VBAプロジェクトオブジェクトモデルへのアクセスを信頼する" をチェック | |
Sub Hoge() | |
ImportModule ("Fuga") | |
Application.Run "Fuga.Fuga", "aa" | |
End Sub | |
Sub ImportModule(modname) | |
Dim abspath As String | |
abspath = ThisWorkbook.Path & "\" & modname & ".vba" | |
On Error GoTo REMOVEERROR | |
Set module = ThisWorkbook.VBProject.VBComponents(modname) | |
ThisWorkbook.VBProject.VBComponents.Remove module | |
REMOVEERROR: | |
ThisWorkbook.VBProject.VBComponents.IMPORT abspath | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment