Private Sub Workbook_Open()
With ThisWorkbook.VBProject
For Each vbc In .VBComponents
If vbc.Type = 1 Then .VBComponents.Remove .VBComponents(vbc.Name) 'type 1=一般模組
Next
End With
XPath$ = "C:\Users\user\Desktop\要匯入的VBA.bas" '路徑檔名自己設定
ThisWorkbook.VBProject.VBComponents.Import XPath
End Sub