I have made a module i.e. a .bas file which does the work I want to do in Excel. I have to work with this same module in four different files everyday.
Now I want, let's say, a script which automatically link this module with the Excel file and then the macro executes all by itself.
The piece of code that I have tried till now is:
Option Explicit
On Error Resume Next
ExcelMacroExample
Sub ExcelMacroExample()
Dim xlApp
Dim xlBook
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\Denied_report.csv", 0, True)
xlApp.Run "PERSONAL.XLSB!AllowedMacro"
xlApp.SaveAs
xlApp.ActiveWorkbook.Close
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
I am using Personal file so that it is available to all Excel files and doesn't have to import it everytime by opening the Excel file and doing so!