|
変数の宣言がめちゃくちゃだったんで、2回目。
Sub MD_IMPORT()
Dim wkAgstr As String, wkAgt As Workbook
Dim wkAfilename As String
Dim WB As Workbook, OK As Boolean
wkAfilename = InputBox("ファイル名を入力してください")
wkAgstr = "C:\" & wkAfilename & ".xls"
'wkAgstr = ThisWorkbook.Path & "\マクロをインポートされるブック.xls"
If Dir(wkAgstr) = "" Then End
For Each WB In Workbooks
If WB.Name = Dir(wkAgstr) Then
OK = True
End If
Next
If OK Then
Set wkAgt = Workbooks(Dir(wkAgstr))
Else
Set wkAgt = Workbooks.Open(wkAgstr)
End If
With wkAgt.VBProject.VBComponents
.Import ("D:\インポート元ファイル\Module1.bas")
'.Import (ThisWorkbook.Path & "\Module1.bas")
End With
End Sub
|
|