PDA

View Full Version : Problems running macro from another workbook



udigold1
01-15-2009, 07:43 AM
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

Bob Phillips
01-15-2009, 08:01 AM
Maybe try



Application.Run "'" & trBook.Name & "'!PitzulMethod"

georgiboy
01-15-2009, 08:05 AM
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