Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default run macro in book1 from book2 - how?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default run macro in book1 from book2 - how?

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
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
VBA - Testing for Book1, Book2 etc. dhstein Excel Discussion (Misc queries) 1 May 22nd 09 10:12 AM
Transfer info book1 to book2 israel New Users to Excel 3 January 23rd 09 07:14 PM
Book1 and Book2 JohnR Excel Discussion (Misc queries) 2 July 6th 07 02:10 AM
=SUMIF(book2!L3:AF3, "=book1!O30", book2!L20:AF20) dond Excel Discussion (Misc queries) 1 November 8th 05 12:33 PM
IE to Book1, to book2, then close Book1.xls GotDebt Excel Programming 3 December 5th 03 08:31 PM


All times are GMT +1. The time now is 05:18 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"