Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Calling xla argumented macro from VBScript

Hi,

I'm trying to call a macro with 1 argument from VBScript
but the VBA code doesn't get executed.
I've no problem when calling a macro without arguments.
Is it possible to call a Excel macro with arguments
through automation?

vbscript:

Const vbNormal = 1 ' window style
DIM objXL, objWb ' Excel object variables

Set objXL = WScript.CreateObject ("Excel.Application")
objXL.WindowState = vbNormal
objXL.Visible = true
Set objWb = objXL.WorkBooks.Open("C:\TEMP\test.xla")
objXL.Run "data_pump","C:\TEMP\test.xml"

xla VBA code

Public Sub data_pump(sFileUri As Variant)
Application.Workbooks.Open (CStr(sFileUri))
End Sub

Thanks for the support,

Lieven
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Calling xla argumented macro from VBScript

I used this in my VBA code:

Option Explicit
Sub data_Pump(mystr As String)
MsgBox mystr
End Sub


And my workbook was not in c:\temp\test.xla, but this seemed to work ok:

Const vbNormal = 1 ' window style
Dim objXL, objWb ' Excel object variables

Set objXL = CreateObject("Excel.Application")
objXL.WindowState = vbNormal
objXL.Visible = True
Set objWb = objXL.WorkBooks.Open("book1.xls")
objXL.Run "book1.xls!data_Pump", "C:\TEMP\test.xml"

===
I also tested from MSWord, so I dropped the WScript. bit, too.



Lieven Roelens wrote:

Hi,

I'm trying to call a macro with 1 argument from VBScript
but the VBA code doesn't get executed.
I've no problem when calling a macro without arguments.
Is it possible to call a Excel macro with arguments
through automation?

vbscript:

Const vbNormal = 1 ' window style
DIM objXL, objWb ' Excel object variables

Set objXL = WScript.CreateObject ("Excel.Application")
objXL.WindowState = vbNormal
objXL.Visible = true
Set objWb = objXL.WorkBooks.Open("C:\TEMP\test.xla")
objXL.Run "data_pump","C:\TEMP\test.xml"

xla VBA code

Public Sub data_pump(sFileUri As Variant)
Application.Workbooks.Open (CStr(sFileUri))
End Sub

Thanks for the support,

Lieven


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Calling xla argumented macro from VBScript

Apparently it works with an .xls file and not with
an .xla file.
-----Original Message-----
I used this in my VBA code:

Option Explicit
Sub data_Pump(mystr As String)
MsgBox mystr
End Sub


And my workbook was not in c:\temp\test.xla, but this

seemed to work ok:

Const vbNormal = 1 ' window style
Dim objXL, objWb ' Excel object variables

Set objXL = CreateObject("Excel.Application")
objXL.WindowState = vbNormal
objXL.Visible = True
Set objWb = objXL.WorkBooks.Open("book1.xls")
objXL.Run "book1.xls!data_Pump", "C:\TEMP\test.xml"

===
I also tested from MSWord, so I dropped the WScript.

bit, too.



Lieven Roelens wrote:

Hi,

I'm trying to call a macro with 1 argument from

VBScript
but the VBA code doesn't get executed.
I've no problem when calling a macro without arguments.
Is it possible to call a Excel macro with arguments
through automation?

vbscript:

Const vbNormal = 1 ' window style
DIM objXL, objWb ' Excel object variables

Set objXL = WScript.CreateObject ("Excel.Application")
objXL.WindowState = vbNormal
objXL.Visible = true
Set objWb = objXL.WorkBooks.Open("C:\TEMP\test.xla")
objXL.Run "data_pump","C:\TEMP\test.xml"

xla VBA code

Public Sub data_pump(sFileUri As Variant)
Application.Workbooks.Open (CStr(sFileUri))
End Sub

Thanks for the support,

Lieven


--

Dave Peterson

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling AutoFit using macro in XLCALL.h [email protected] Excel Discussion (Misc queries) 1 January 9th 08 03:46 PM
calling macro in a formula rk0909 Excel Discussion (Misc queries) 2 March 14th 06 04:15 PM
calling a macro from within a loop Rick[_12_] Excel Programming 1 July 30th 03 11:52 PM
calling a macro from within a loop Mike Hughes Excel Programming 0 July 30th 03 08:50 PM
Calling macro in add-in. Clark B Excel Programming 1 July 24th 03 11:05 PM


All times are GMT +1. The time now is 06:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"