How can i run macro function in .xlsx file..?


I have a different kind of macro functions in a separate file like (Marco.xlsm)
Based on the input file, i want to call the correct macro function.

Is this possible to run the macro function in .xlsx format.?
If yes, please give the solution.

For Example: - If i call the Macro Function from the Macro.xlsm file, the changes will be happened in .xlsx file.

Thanks in advance.

Poovarasan Gunasekaran

The answer is yes.
You need just reference to .xlsx file.
I have run the macro from .xlsm and updated the .xlsx file.

Sub Test()

    Dim OtherWorkbook As Workbook

    Application.DisplayAlerts = False
    'Otherworkbook should be closed at start of code.
    'We open it here.
    Set OtherWorkbook = Workbooks.Open("D:\Excel Projects\Result.xlsx")
    With OtherWorkbook
        .Worksheets("Sheet1").Range("A1") = "I've just updated the other workbook."
    End With
    Application.DisplayAlerts = True

End Sub

Hi @Poovarasan2

Another way would be to open your file in the Excel Application Scope and use the Invoke VBA activity :slight_smile:


Thanks @loginerror,
Now it is Working.:+1::+1:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.