Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel E-2007 starts, but Installer also starts 3 times??? | Setting up and Configuration of Excel | |||
starts with decimal point only if number is like 0.###... | Excel Worksheet Functions | |||
Excel Starts up w/a Personal Macro page | Excel Discussion (Misc queries) | |||
creating macro to ask for variable info when excel starts | Excel Programming | |||
Refer to a Name saved prior my macro Starts from VBA excel | Excel Programming |