' ============================================================
' JUK Import - Simple Version
' ============================================================
Option Explicit

Sub ImportJukModules()
    Const MODULE_PATH As String = "D:\Project\upds7\vba\src\sh\juk\module"
    
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    If Not fso.FolderExists(MODULE_PATH) Then
        MsgBox "Folder not found"
        Exit Sub
    End If
    
    Dim file As Object
    For Each file In fso.GetFolder(MODULE_PATH).Files
        If LCase(fso.GetExtensionName(file.Name)) = "bas" Then
            Dim modName As String
            modName = fso.GetBaseName(file.Name)
            
            On Error Resume Next
            ThisWorkbook.VBProject.VBComponents.Remove ThisWorkbook.VBProject.VBComponents(modName)
            
            ThisWorkbook.VBProject.VBComponents.Import file.Path
            
            If Err.Number <> 0 Then
                MsgBox "Error: " & Err.Description & " (" & Err.Number & ")"
                Exit Sub
            End If
            
            On Error GoTo 0
            Debug.Print "Imported: " & modName
        End If
    Next
    
    MsgBox "Done"
End Sub