• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

I am getting run time error 1004. Anybody please help me in this.

ThrottleWorks

Excel Ninja
Sir, I want to run a macro from another workbook. I am giving follwing code to the macro


application.run ("sachin.xlsm!single") but I am getting a bug.


I am getting run time error 1004. Anybody please help me in this.
 
Unfortunately, the run time error code seems to be a default "SOMETHING WENT WRONG!!" kind of error. Is the other workbook already open when you are trying to run the macro? Is the name of everything correct (watch out for case-sensitivity)?
 
Sir, yes another file is already open when trying to run the macro, infact i have two files, file 1 & file 2


I am opening the file 2 from the code written in file 1,


file 1 has a module, which opens the file 2, the same code is trying to run a module which is in file 2


File 1 - module 1 - open file 2


file 1 - module 1 - run the code which is in file 2


sorry for making it so complicated, thanks for your support.
 
It looks like the Single is a reserved word, as it refers to a type of variable. I think you just need to change the name of the macro.
 
Sir, I also tried by chaning the name, but it is not working, I think I am doing some spelling mistake,I will post my error if I am able to found, thanks very much for your valuable time & support.
 
Hi Sachin ,


As Luke has already pointed out , you cannot use the name "Single" for a procedure ; the syntax for calling a macro which is in another workbook is :


Application.Run "'The other workbook name'!Macroname"


In your case , this will be :


application.run "'sachin.xlsm'!single_1"


Narayan
 
Sir, Thanks for the reply, what should I write in the below example


File Name - Sachin

Module Name - One_Trade

Sub Name - Singlee_Trade


I am writing following code - application.run "'Sachin.xlsm'!One_Trade"


The macro is opening Sachin.xlsm. it is even opening the code window.

But it is not running the macro, I am getting messege like "Run Time Error 1004"


Cannot run the macro "Sachn.xlsm'!one_Trade'.


The macro may not be available in this workbook or all macros may be disabled.


Thaks your support & time.
 
Hi Sachin ,


You cannot use the Module name to call a procedure.


Change your call to :


Application.Run "'Sachin.xlsm'!Singlee_Trade"


Narayan


P.S. Going by the error message , it is a problem of the file name Sachn instead of Sachin ; rename your file to Sachin.xlsm
 
Narayan Sir, Luke Sir, & Chandoo Forum thanks a lot, it has worked.


I was sure, I making a silly mistake somewhere, Thanks all for your valuable time, patience & great support.
 
Back
Top