Put a Macro into other Excel files

  • Thread starter Thread starter ducttape
  • Start date Start date
D

ducttape

I have written a macro which is used to log the time a file is open.
would now like to save this macro into every file in a folder on th
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 Wit
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top