How to run a macro without opening the Excel file using a Visual Basic Script. You may also refer to the video how to import data into Excel from a Word table.
Watch the training video below:
Watch this video on YouTube
We first create a file called “myVBScript.vbs” using notepad. In this file we run the macro in Module1 using this line of code:
After the Excel Application is launched, we execute the ‘importTableDataWord’ in module1 in file how-to-import-data-from-Word-tables-into-Excel-with-VBA.xlsm located on the desktop. Important to note is how path to the file is located. We use first double-quotes and then an apostrophe. The quotes are closed at the end but the apostrophe is closed after the Excel file extension ‘xlsm’.
This line of code does not allow alerts to be displayed so that no user intervention is required: objExcel.DisplayAlerts = False
The next line closes the apllication: objExcel.Application.Quit
The last line of code frees memory: Set objExcel = Nothing