Run Macro Automatically without Opening Excel File

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:

objExcel.Application.Run “‘C:\Users\takyar\Desktop\how-to-import-data-from-Word-tables-into-Excel-with-VBA.xlsm’!Module1.importTableDataWord”

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

Further reading:

How to Import Data from Word Tables into Excel with VBA

Published by

Dinesh Kumar Takyar

Welcome to! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: For a structured Excel VBA training course online you can visit:

2 thoughts on “Run Macro Automatically without Opening Excel File”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.