Running a Subroutine on Open ABNORMALLY

hicksi

Board Regular
Joined
Mar 5, 2012
Messages
167
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:

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

hicksi

Board Regular
Joined
Mar 5, 2012
Messages
167
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:

Watch MrExcel Video

Forum statistics

Threads
1,109,433
Messages
5,528,738
Members
409,831
Latest member
KT50

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top