Consulting

Results 1 to 3 of 3

Thread: Problems running macro from another workbook

  1. #1

    Problems running macro from another workbook

    Hi,

    I'm trying to run a macro from another workbook, but I'm having problems,
    I get "run time error 1004, cannot run the macro..."
    The code which I use:

     
    '****** Variables for Origin File ******
    Dim ph As Range
    Dim fl As Range
    Set fl = Range("filepitzul")
    Set ph = Range("pathpitzul")
    '****** End Variables ******
    Workbooks.Open ph & "\" & fl 
     
    '****** Variables for Target File ******
    Dim trBook As Workbook
    Set trBook = Workbooks(fl.Value)
    '****** End Variables ******
     
    Application.Run (trBook.Name & "!PitzulMethod")
    The security settings are set to mininum and the macro does exist...
    Can anyone help, please?

    Thanks

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Maybe try

    [vba]

    Application.Run "'" & trBook.Name & "'!PitzulMethod"
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    If the workbook you are opening needs this macro to be run everytime the workbook is opened you could put it in a Auto_Open macro or place it in a Workbook_Open event in the workbook you are opening.

    Have you also tried Call to run the macro "Call Macro1".

    Hope this helps
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

Posting Permissions

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