Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to call macro from other workbook


Hi,

I m running a macro from one of the excel workbook let s say workbook1
i want to add a call macro code so that i can execute the macro in othe
workbook2.

Guys, do u have any idea/

Thanks,
ppyx

--
ppyx
-----------------------------------------------------------------------
ppyxl's Profile: http://www.excelforum.com/member.php...fo&userid=3611
View this thread: http://www.excelforum.com/showthread.php?threadid=56064

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default How to call macro from other workbook

Application.Run "book2.xls!test_msgbox"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"ppyxl" wrote in
message ...

Hi,

I m running a macro from one of the excel workbook let s say workbook1,
i want to add a call macro code so that i can execute the macro in other
workbook2.

Guys, do u have any idea/

Thanks,
ppyxl


--
ppyxl
------------------------------------------------------------------------
ppyxl's Profile:

http://www.excelforum.com/member.php...o&userid=36116
View this thread: http://www.excelforum.com/showthread...hreadid=560641



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to call macro from other workbook


Like this:

Application.Run "Workbook1!MyMacro"



Col


--
colofnature
------------------------------------------------------------------------
colofnature's Profile: http://www.excelforum.com/member.php...o&userid=34356
View this thread: http://www.excelforum.com/showthread...hreadid=560641

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to call macro from other workbook


code is not working, pls check for me. Many thanks
____________________________
Sub SaveFO2()

-'define date-

Dim ReportDate, LsReportDate As Date
Dim ReportName, directoryName As String

LsReportDate = Workbooks("startup").Sheets("FO2").Range("B2")
ReportDate = Workbooks("startup").Sheets("FO2").Range("B3")

-'save from one file to another-

Workbooks.Open fileName:=("K:\Reporting\XL\DataBase\FO2 "
Format(LsReportDate, "yyyymmdd") & ".xls"), updatelinks:=0

ActiveWorkbook.SaveAs "K:\Reporting\XL\DataBase\FO2 "
Format(ReportDate, "yyyymmdd") & ".xls"

-'define some strings-
directoryName = "K:\Reporting\XL\DataBase\FO2 " & Format(ReportDate
"yyyymmdd")
ReportName = "FO2 " & Format(ReportDate, "yyyymmdd") & ".xls"

Sheets("Input_Working").Activate
Cells(2, 4).Value = ReportDate

-'run macro-
Application.Run ReportName!Main

End Su

--
ppyx
-----------------------------------------------------------------------
ppyxl's Profile: http://www.excelforum.com/member.php...fo&userid=3611
View this thread: http://www.excelforum.com/showthread.php?threadid=56064

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to call macro from other workbook

Application.Run ReportName & "!Main"

--
Regards,
Tom Ogilvy


"ppyxl" wrote:


code is not working, pls check for me. Many thanks
____________________________
Sub SaveFO2()

-'define date-

Dim ReportDate, LsReportDate As Date
Dim ReportName, directoryName As String

LsReportDate = Workbooks("startup").Sheets("FO2").Range("B2")
ReportDate = Workbooks("startup").Sheets("FO2").Range("B3")

-'save from one file to another-

Workbooks.Open fileName:=("K:\Reporting\XL\DataBase\FO2 " &
Format(LsReportDate, "yyyymmdd") & ".xls"), updatelinks:=0

ActiveWorkbook.SaveAs "K:\Reporting\XL\DataBase\FO2 " &
Format(ReportDate, "yyyymmdd") & ".xls"

-'define some strings-
directoryName = "K:\Reporting\XL\DataBase\FO2 " & Format(ReportDate,
"yyyymmdd")
ReportName = "FO2 " & Format(ReportDate, "yyyymmdd") & ".xls"

Sheets("Input_Working").Activate
Cells(2, 4).Value = ReportDate

-'run macro-
Application.Run ReportName!Main

End Sub


--
ppyxl
------------------------------------------------------------------------
ppyxl's Profile: http://www.excelforum.com/member.php...o&userid=36116
View this thread: http://www.excelforum.com/showthread...hreadid=560641




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to call macro from other workbook


Hi, thanks!

error msg still! macro not found

is it any speical setting for the macro in another excel work book


--
ppyxl
------------------------------------------------------------------------
ppyxl's Profile: http://www.excelforum.com/member.php...o&userid=36116
View this thread: http://www.excelforum.com/showthread...hreadid=560641

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to call macro from other workbook

the macro should be in a general module and not in a sheet module or the
thisworkbook module. the macro should be public, but this is the default.

--
Regards,
Tom Ogilvy


"ppyxl" wrote:


Hi, thanks!

error msg still! macro not found

is it any speical setting for the macro in another excel work book


--
ppyxl
------------------------------------------------------------------------
ppyxl's Profile: http://www.excelforum.com/member.php...o&userid=36116
View this thread: http://www.excelforum.com/showthread...hreadid=560641


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default How to call macro from other workbook

Try

Application.Run "'" & ReportName & "'!Main"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"ppyxl" wrote in
message ...

Hi, thanks!

error msg still! macro not found

is it any speical setting for the macro in another excel work book


--
ppyxl
------------------------------------------------------------------------
ppyxl's Profile:

http://www.excelforum.com/member.php...o&userid=36116
View this thread: http://www.excelforum.com/showthread...hreadid=560641



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to call macro from other workbook

Good catch on Bob's part - Spaces in a workbook name require the name be
enclosed in single quotes.

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote:

the macro should be in a general module and not in a sheet module or the
thisworkbook module. the macro should be public, but this is the default.

--
Regards,
Tom Ogilvy


"ppyxl" wrote:


Hi, thanks!

error msg still! macro not found

is it any speical setting for the macro in another excel work book


--
ppyxl
------------------------------------------------------------------------
ppyxl's Profile: http://www.excelforum.com/member.php...o&userid=36116
View this thread: http://www.excelforum.com/showthread...hreadid=560641


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
Call Macro from another WorkBook? Steven M. Britton[_2_] Excel Programming 6 June 10th 05 04:33 PM
How to call Macro(using ExecuteExcel4Macro) for a particular workbook [email protected] Excel Programming 6 December 22nd 04 11:23 AM
How can I call a macro in another workbook? ned Excel Programming 4 May 31st 04 09:50 PM
Open Another Workbook and Call Macro Bill Oertell[_2_] Excel Programming 1 January 20th 04 04:29 AM
Call a macro in other workbook Davwe[_4_] Excel Programming 2 December 17th 03 08:14 PM


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