Running a Subroutine on Open ABNORMALLY

hicksi

Board Regular
Joined
Mar 5, 2012
Messages
214
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I have Excel as my data with a set of forms (ie, a system utilising Excel - because I CANNOT use C# or VB# due to company policy).
Usually it starts and displays the main form... NO PROBLEM
It also contains code-save & sheet-save subroutines. I want to run those (without running the forms).

Is there a command-line version such as
Code:
EXCEL MYFILE.XLSM -RUN ExportCode
which will open MYFILE.XLSM and run my ExportCode subroutine and then exit?
 
Last edited:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
And I just found THIS code on https://wellsr.com/vba/2015/excel/run-macro-without-opening-excel-using-vbscript/

Code:
<code class="language-vb" data-lang="vb">
'Code should be placed in a .vbs file 
</code><code class="language-vb" data-lang="vb">Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Run "'C:\Users\Ryan\Desktop\Sales.xlsm'!SalesModule.SalesTotal"
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing</code>

Haven't tried it (yet)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,117
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top