I know you can do this via a VBS file, copy the following and paste into notepad and save with a .vbs extension:
Code:
Option Explicit
On Error Resume Next
ExcelMacroExample
Sub ExcelMacroExample()
Dim xlApp
Dim xlBook
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\temp\Book1.xlsm", 0, True)
xlApp.Run "MyFunction"
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
Adjust the workbook location and Function name to your function you wish to execute.
If you need to run this as a command I'm sure you could execute "wscript yourfile.vbs", or perhaps cscript instead.
If you need to do this within your own program you are righting without any external scripting Microsoft...