Click to See Complete Forum and Search --> : running excel macro outside excel


vbnov
February 18th, 2006, 10:30 AM
guys

how do i run a macro outside excel using vbscript? thanks in advance

Rich2189
February 19th, 2006, 05:14 AM
open a text editor copy your code in and save it as a .vbs file.

as a simple test write this line in the .vbs file



msgbox "VBS"



To run it, double click on the .vbs file

if you have used any objects you will have to create them manually.

Rich

vbnov
February 20th, 2006, 01:43 PM
guys

i finally found how to call a macro outside excel. Now the problem is how to pass dynamic values .

sample code follows,

VBScript

Option Explicit

Private Sub Command1_Click()
Dim oExcelApp As Object

' Create a reference to the currently running excel application
Set oExcelApp = GetObject(, "Excel.application")
' Make the Excel Application Visible.
oExcelApp.Visible = True
' Run the excel procedure
oExcelApp.run "proc", "David", 30
End Sub



Excel macro

Sub Proc(sParam1 As String, iParam2 As Integer)
MsgBox sParam1 & " is " & iParam2 & " Years Old"
End Sub

Thanks

vbnov
February 20th, 2006, 02:27 PM
Thnx guys

found out how to do it

bluesea1
October 30th, 2011, 10:58 PM
Hi,

though it's VERY old thread, I'd like to get back to it:

vbnov, I am having exactly the same problem. You say you solved it.

Could you please let me know how you did it?

Thanks a lot!
James

Raygar
November 18th, 2011, 07:59 PM
It's an interesting concept.
I'd love to be able to call macros from a closed Excel file, but I don't think that's possible.