I found this code BUT the only thing wrong with it goes to the personal.xls I want it to go to the VBAProdject ThisWorkBook
The current workbook I opened up.
Can it search for a wild card like a ? mark or a *
Example: VBAProdject(Negative Inventory?.xls)
OR
VBAProdject(Negative Inventory*.xls)
Sub CopyModulesFromA()
Dim FS As Office.FileSearch
Dim vaFileName As Variant
Set FS = Application.FileSearch
With FS
'clear old search criteria
.NewSearch
'directory to search
.LookIn = "C:"
'look for .bas (Module) files
.Filename = "*Inventory.bas"
'carry out search
.Execute
For Each vaFileName In .FoundFiles
MsgBox "About to import module " & vaFileName
Workbooks("Negative Inventory as of 09-10-2004.xls").VBProject.VBComponents.Import Filename:=vaFileName
Next vaFileName
End With
End Sub
I changed it to look like this but it does not work:
Workbooks("Negative Inventory as of*.xls").VBProject.VBComponents.Import Filename:=vaFileName
Bookmarks