Run Time 1004 error when calling sub from another macro
Eliminate Pivot Table Annoyances
Thanks Thanks:  0
Likes Likes:  0
Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: Run Time 1004 error when calling sub from another macro

  1. #1
    Board Regular
    Join Date
    Aug 2011
    Posts
    65
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Run Time 1004 error when calling sub from another macro

     
    I am tryingto run a macro existing in another workbook opened by a variable, I am using the following code to try and get it to work but i get Run-time error '1004':

    Cannot run the macro "Test 5.xlsm'!UpdTables'. The macro may not be available or all macros may be disabled.


    Code:
     
    Application.Run "'" & Application.ActiveWorkbook.Name & "'!UpdTables"

  2. #2
    MrExcel MVP shg's Avatar
    Join Date
    May 2008
    Location
    The Great State of Texas
    Posts
    19,940
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run Time 1004 error when calling sub from another macro

    Is the macro in a standard module (e.g., not in a sheet module)?

  3. #3
    Board Regular
    Join Date
    Aug 2011
    Posts
    65
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run Time 1004 error when calling sub from another macro

    no it is in a sheet labeled: Box

  4. #4
    MrExcel MVP
    Join Date
    Mar 2004
    Location
    Canada
    Posts
    17,809
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run Time 1004 error when calling sub from another macro

    Then, as shg is already suggesting, you'll need to place your UpdTables macro in a standard module.

  5. #5
    Board Regular
    Join Date
    Aug 2011
    Posts
    65
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run Time 1004 error when calling sub from another macro

    Moved into module1 removed from the sheet, same error

  6. #6
    MrExcel MVP
    Join Date
    Mar 2004
    Location
    Canada
    Posts
    17,809
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run Time 1004 error when calling sub from another macro

    I'm assuming that...

    1) macros have been enabled, and;

    2) 'Test 5.xlsm' contains the UpdTables macro.

    Is this correct?

  7. #7
    Board Regular
    Join Date
    Aug 2011
    Posts
    65
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run Time 1004 error when calling sub from another macro

    Both assumptions are correct. I can run the macro from within the (test 5)workbook itself, but not when called from the other workbook (Test Master)
    Last edited by Curben; Jan 19th, 2012 at 04:33 PM.

  8. #8
    Board Regular
    Join Date
    Dec 2011
    Posts
    3,638
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run Time 1004 error when calling sub from another macro

    Hi

    When it bugs out, what does this return when entered in the Immediate Window of the VBE (open this up with Ctrl+g if you have to):

    ?"'" & Application.ActiveWorkbook.Name & "'!UpdTables"

    Don't miss the leading ? above. Does this tally with what you expect (ie is the workbook name correct)?

  9. #9
    MrExcel MVP shg's Avatar
    Join Date
    May 2008
    Location
    The Great State of Texas
    Posts
    19,940
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run Time 1004 error when calling sub from another macro

    1. Are you sure that the workbook that contains the macro is active when you execute the statement?

    2. Does your statement work if you put in the workbook that contains the macro, with that worbook active?

    Code:
    Application.Run "'" & Application.ActiveWorkbook.Name & "'!UpdTables"

  10. #10
    Board Regular
    Join Date
    Aug 2011
    Posts
    65
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run Time 1004 error when calling sub from another macro

      
    That helped me find the ID-10-T error
    Trying things on my own I switched from
    Code:
    Application.Run "'" & Application.ActiveWorkbook.Name & "'!UpdTables"
    TO
    Code:
    Application.Run Application.ActiveWorkbook.Name & "!UpdTables"

    the test you gave showed me the slight syntax difference and I reverted the call, it works now thanks everyone.

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com