MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Saving an Excel macro as a .VBS file

Posted by Amir on August 13, 2001 2:51 PM

How can I save an Excel macro as a .VBS file? I need it for an application that can execute only VB Script files.

Posted by Damon Ostrander on August 13, 2001 10:19 PM


I don't believe that Excel contains a mechanism for generating VBS code. This is because VBS is only a subset of VBA--VBA contains a number of features not supported by VBS. Obviously though, if you have written your VBA code so that it does not use any features not supported by VBS, you can simply copy and paste the code from the VBE to the VBscript editor. The VBscript VBE can also read .bas source code text files written by the Excel VBE. Just right-click on a macro module in the VBscript VBE and select Import.