Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default VBS starts Excel. How to point to different macro when run?

I have the folloining code in a file called RaceBetting.vbs. When run, it
startes the the RaceBetting.xls and runs the "AutoOpen" macro. I would like
to point it to run a different macro when run. Below the:
XLApp.ActiveWorkbook.RunAutoMacros 1
points to a number. How do I relate this to the macros?
The Macro I want to run is "ImportRaceProgramData()" instead of the
Auto_Open()

---------------------
Dim XLApp
Dim XLWkb
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = true
XLApp.Workbooks.Open "RaceBetting.xls"
XLApp.ActiveWorkbook.RunAutoMacros 1
--------------------

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default VBS starts Excel. How to point to different macro when run?

In Excel the syntax is like this:

Application.Run "WhateverWorkbook.xls!ModuleName.ProcedureName ", Argument1,
Argument2

So it looks you will need:

XLApp.Run "RaceBetting.xls!ModuleName.ImportRaceProgramD ata"


RBS


"CRayF" wrote in message
...
I have the folloining code in a file called RaceBetting.vbs. When run, it
startes the the RaceBetting.xls and runs the "AutoOpen" macro. I would
like
to point it to run a different macro when run. Below the:
XLApp.ActiveWorkbook.RunAutoMacros 1
points to a number. How do I relate this to the macros?
The Macro I want to run is "ImportRaceProgramData()" instead of the
Auto_Open()

---------------------
Dim XLApp
Dim XLWkb
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = true
XLApp.Workbooks.Open "RaceBetting.xls"
XLApp.ActiveWorkbook.RunAutoMacros 1
--------------------


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default VBS starts Excel. How to point to different macro when run?

Im getting a error: C:\xxxxxx\xxxxxRaceBetting.vbs
Line 6 Char 1
The macro €˜RaceBetting.xls!ModuleName.ImportRaceProgramDat a cannot be found€¦

When I go to Macros and edit ImportRaceProgramData
On the Alphabetic (vs Categorized) TAB it is listed as:
(Name) ImportRaceProgramData

On the top left, under the VBAProject(RaceBetting.xls)
Under the Modules TAB I have 2 moduls listed.:
AutoStarted (and)
ImportRaceProgramData

I think ImportRaceProgramData once said Modual1 or something but I though I
changed this by typing over it in the (Name) on the bottom left. As mentioned
above it says ImportRaceProgramData.

-----------------
Dim XLApp
Dim XLWkb
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = true
XLApp.Workbooks.Open "RaceBetting.xls"
XLApp.Run "RaceBetting.xls!ModuleName.ImportRaceProgramD ata"
------------------



"RB Smissaert" wrote:

In Excel the syntax is like this:

Application.Run "WhateverWorkbook.xls!ModuleName.ProcedureName ", Argument1,
Argument2

So it looks you will need:

XLApp.Run "RaceBetting.xls!ModuleName.ImportRaceProgramD ata"


RBS


"CRayF" wrote in message
...
I have the folloining code in a file called RaceBetting.vbs. When run, it
startes the the RaceBetting.xls and runs the "AutoOpen" macro. I would
like
to point it to run a different macro when run. Below the:
XLApp.ActiveWorkbook.RunAutoMacros 1
points to a number. How do I relate this to the macros?
The Macro I want to run is "ImportRaceProgramData()" instead of the
Auto_Open()

---------------------
Dim XLApp
Dim XLWkb
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = true
XLApp.Workbooks.Open "RaceBetting.xls"
XLApp.ActiveWorkbook.RunAutoMacros 1
--------------------



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default VBS starts Excel. How to point to different macro when run?

I hope to answer this query as well as you last question in "Passing
parms to a VBS file or a macro when executed?" here.

1. I have an Excel file called C:\RaceBetting.xls.

2. This file has a module called ImportRaceProgramData - name changed in
the Properties window.

3. In the ImportRaceProgramData module is a macro called
ImportRaceProgramData ( Personally I would have left the module called
Module1 so as to avoid confusion).

4. The macro looks like this:
Sub ImportraceProgramData(passed_filename)
MsgBox passed_filename
End Sub

5. I have a vbscipt file called c:\RaceBetting.vbs.

6. The script looks like this
------------------------------------------------------------------------
Set WshShell = WScript.CreateObject("WScript.Shell")
passed_name = WScript.Arguments(0)
Dim XLApp
Dim XLWkb
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = true
XLApp.Workbooks.Open "C:\RaceBetting.xls"
XLApp.ActiveWorkbook.RunAutoMacros 1
XLApp.Run _
"RaceBetting.xls!ImportRaceProgramData.ImportRaceP rogramData" _
, passed_name
Set XlApp = Nothing
Set WshShell = Nothing
----------------------------------------------------------------------------
Note: I have doubts about this line actually suppressing automacros eg
the Workbook_Open event:
XLApp.ActiveWorkbook.RunAutoMacros 1

7. On the command prompt I enter c:\RaceBetting.vbs MyFile.xls

8. The excel workbook is opened and a msgbox appears reading MyFile.xls

I hope this helps
Rowan

CRayF wrote:
Im getting a error: C:\xxxxxx\xxxxxRaceBetting.vbs
Line 6 Char 1
The macro €˜RaceBetting.xls!ModuleName.ImportRaceProgramDat a cannot be found€¦

When I go to Macros and edit ImportRaceProgramData
On the Alphabetic (vs Categorized) TAB it is listed as:
(Name) ImportRaceProgramData

On the top left, under the VBAProject(RaceBetting.xls)
Under the Modules TAB I have 2 moduls listed.:
AutoStarted (and)
ImportRaceProgramData

I think ImportRaceProgramData once said Modual1 or something but I though I
changed this by typing over it in the (Name) on the bottom left. As mentioned
above it says ImportRaceProgramData.

-----------------
Dim XLApp
Dim XLWkb
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = true
XLApp.Workbooks.Open "RaceBetting.xls"
XLApp.Run "RaceBetting.xls!ModuleName.ImportRaceProgramD ata"
------------------



"RB Smissaert" wrote:


In Excel the syntax is like this:

Application.Run "WhateverWorkbook.xls!ModuleName.ProcedureName ", Argument1,
Argument2

So it looks you will need:

XLApp.Run "RaceBetting.xls!ModuleName.ImportRaceProgramD ata"


RBS


"CRayF" wrote in message
...

I have the folloining code in a file called RaceBetting.vbs. When run, it
startes the the RaceBetting.xls and runs the "AutoOpen" macro. I would
like
to point it to run a different macro when run. Below the:
XLApp.ActiveWorkbook.RunAutoMacros 1
points to a number. How do I relate this to the macros?
The Macro I want to run is "ImportRaceProgramData()" instead of the
Auto_Open()

---------------------
Dim XLApp
Dim XLWkb
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = true
XLApp.Workbooks.Open "RaceBetting.xls"
XLApp.ActiveWorkbook.RunAutoMacros 1
--------------------



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
Excel E-2007 starts, but Installer also starts 3 times??? Thanks for the Great Tip Setting up and Configuration of Excel 0 January 24th 10 03:21 AM
starts with decimal point only if number is like 0.###... markx Excel Worksheet Functions 3 September 14th 07 12:10 PM
Excel Starts up w/a Personal Macro page Parker Excel Discussion (Misc queries) 4 August 29th 05 09:31 PM
creating macro to ask for variable info when excel starts Flyriverside Excel Programming 1 April 7th 04 06:32 PM
Refer to a Name saved prior my macro Starts from VBA excel [email protected] Excel Programming 1 January 21st 04 11:47 AM


All times are GMT +1. The time now is 02:13 PM.

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

About Us

"It's about Microsoft Excel"