May 03 2021 03:55 AM - edited May 03 2021 04:24 AM
Hi Team,
I am calling a macro from the below vbscript. Macro has the code to open multiple workbooks and process them. When executing the macro from Run button, the workbooks are opening fine and the contents are visible. But when calling the macro from vbscript, the workbooks are opening, but the content section is not visible.
---------
Option Explicit
On Error Resume Next
ExcelMacroExample
Sub ExcelMacroExample()
Dim xlApp
Dim xlBook
Dim WshShell
Dim strCurDir
Dim mergerFile
Set WshShell = CreateObject("WScript.Shell")
strCurDir = WshShell.CurrentDirectory
mergerFile = strCurDir + "\Merge_Function_V1.0.xlsm"
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Open(mergerFile)
xlApp.Run "'" & mergerFile & "'!Module1.merge_sheets"
xlBook.Close
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
Kindly share your views.
Thanks
May 04 2021 04:28 PM