Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have a macro in book1 (just a test macro) sub test() Sheets("Sheet1").Range("A1") = "this is a test" End Sub But I want to run this macro from book2. Here is what I tried that did not work from book2 Sub runMacro() Dim bk As Workbook Set bk = Workbooks.Open(ThisWorkbook.Path & "\book1.xls") bk.Application.Run "Test" End Sub I get the error message that it can't find "Test". Could someone share the correct syntax for this? Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Well, I did finally find one thing that worked:
Sub runMacro() Workbooks.Open("Book1.xls") Application.Run "Book1.xls!Test" End Sub But isn't there a way to run this from a workbook object? Set bk = Workbooks("Book1.xls") bk.Application.run "Test" 'which obviously not working -----Original Message----- Hi, I have a macro in book1 (just a test macro) sub test() Sheets("Sheet1").Range("A1") = "this is a test" End Sub But I want to run this macro from book2. Here is what I tried that did not work from book2 Sub runMacro() Dim bk As Workbook Set bk = Workbooks.Open(ThisWorkbook.Path & "\book1.xls") bk.Application.Run "Test" End Sub I get the error message that it can't find "Test". Could someone share the correct syntax for this? Thanks . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA - Testing for Book1, Book2 etc. | Excel Discussion (Misc queries) | |||
Transfer info book1 to book2 | New Users to Excel | |||
Book1 and Book2 | Excel Discussion (Misc queries) | |||
=SUMIF(book2!L3:AF3, "=book1!O30", book2!L20:AF20) | Excel Discussion (Misc queries) | |||
IE to Book1, to book2, then close Book1.xls | Excel Programming |