+ Reply to Thread
Results 1 to 10 of 10

How to call macro from other workbook

  1. #1
    Registered User
    Join Date
    07-06-2006
    Location
    Amsterdam
    Posts
    20

    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 other workbook2.

    Guys, do u have any idea/

    Thanks,
    ppyxl

  2. #2
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Like this:

    Application.Run "Workbook1!MyMacro"



    Col

  3. #3
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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
    >




  4. #4
    Registered User
    Join Date
    07-06-2006
    Location
    Amsterdam
    Posts
    20
    code is not working, pls check for me. Error msg is Objected required
    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

  5. #5
    Tom Ogilvy
    Guest

    Re: 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. #6
    Registered User
    Join Date
    07-06-2006
    Location
    Amsterdam
    Posts
    20

    application.run not working still

    Hi, thanks!

    error msg still! macro not found

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

  7. #7
    Tom Ogilvy
    Guest

    Re: 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. #8
    Tom Ogilvy
    Guest

    Re: 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
    >
    >


  9. #9
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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
    >




  10. #10
    Tom Ogilvy
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1