View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
sqlfan13 sqlfan13 is offline
external usenet poster
 
Posts: 9
Default Call particular Excel function from command line

You could create a simple script, similar to the following, and execute the
script from the command line.

<Code

'Define your Excel application object
Dim objXL
dim moUseSheet

Const C_APP_PATH = "C:\folder\"
Const csUseSheet = "MySpreadsheet.XLS"

'------------------------------------------
' Create an instance of Excel
'------------------------------------------
On Error Resume Next
Set objXL = GetObject(,"Excel.Application")

If TypeName(objXL) < "Application" Then
Set objXL = CreateObject("Excel.Application")
End If

On Error GoTo 0

'Open the file
Set moUseSheet = objXL.Workbooks.Open(C_APP_PATH & csUseSheet)
objXL.Visible = True

'Run Macro
objXL.Application.Run csUseSheet & "!MacroNameToRun"
'Set window size xlNormal
objXL.WindowState = -4143
moUseSheet.Close

Set moUseSheet = Nothing
Set objXL = Nothing

<End Code

Hope this gives you something to go with.


" wrote:

Anyone can teach me how I can trigger e.g. SpreadSheet A - Module B -
Function C from Windows Command Line ? Is there such an
option/partameter ?