+ Reply to Thread
Results 1 to 3 of 3

Put a Macro into other Excel files

  1. #1
    Registered User
    Join Date
    01-12-2006
    Posts
    6

    Put a Macro into other Excel files

    I have written a macro which is used to log the time a file is open. I would now like to save this macro into every file in a folder on the database. Is there a way I can do this using a macro?

    I have located this maco which will loop through each file in a folder, but I am still unsure of how to say, "Save macro X in this file."

    Set wbk = Workbooks.Open("E:\Work_Folders\empty_workbook_1.xls")
    MyDir = wbk.Path

    With Application.FileSearch
    .NewSearch
    .LookIn = MyDir
    .SearchSubFolders = False
    .Filename = ".UPC"
    If .Execute > 0 Then
    Application.ScreenUpdating = False
    For Each vaFileName In .FoundFiles
    'loop through each found workbook
    ProcessData vaFileName
    'pass workbook fullname to process routine
    Next
    Else
    MsgBox "There were no files found."
    End If
    Application.ScreenUpdating = True
    End With

  2. #2
    R.VENKATARAMAN
    Guest

    Re: Put a Macro into other Excel files

    why not park it in personal.xls so that you can use the macro to any file


    "ducttape" <ducttape.21kvlb_1137163803.2768@excelforum-nospam.com> wrote in
    message news:ducttape.21kvlb_1137163803.2768@excelforum-nospam.com...
    >
    > I have written a macro which is used to log the time a file is open. I
    > would now like to save this macro into every file in a folder on the
    > database. Is there a way I can do this using a macro?
    >
    > I have located this maco which will loop through each file in a folder,
    > but I am still unsure of how to say, "Save macro X in this file."
    >
    > Set wbk = Workbooks.Open("E:\Work_Folders\empty_workbook_1.xls")
    > MyDir = wbk.Path
    >
    > With Application.FileSearch
    > NewSearch
    > LookIn = MyDir
    > SearchSubFolders = False
    > Filename = ".UPC"
    > If .Execute > 0 Then
    > Application.ScreenUpdating = False
    > For Each vaFileName In .FoundFiles
    > 'loop through each found workbook
    > ProcessData vaFileName
    > 'pass workbook fullname to process routine
    > Next
    > Else
    > MsgBox "There were no files found."
    > End If
    > Application.ScreenUpdating = True
    > End With
    >
    >
    > --
    > ducttape
    > ------------------------------------------------------------------------
    > ducttape's Profile:

    http://www.excelforum.com/member.php...o&userid=30416
    > View this thread: http://www.excelforum.com/showthread...hreadid=501081
    >




  3. #3
    Registered User
    Join Date
    01-12-2006
    Posts
    6

    Reason for a macro in every file

    adding it to a personal.xls would only allow the macro to be tracking my use of the file. I want it to record whenever anyone in the organization opens a file from the fileshare.

+ Reply to Thread

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