Results 1 to 2 of 2

Import a module file from C:\Drive using a macro?

Threaded View

  1. #1
    Forum Contributor
    Join Date
    09-25-2004
    Posts
    269

    Import a module file from C:\Drive using a macro?

    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
    Last edited by vane0326; 02-13-2005 at 12:14 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1