Macro code can't find file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I create a code in Workbook #1 it works fine. I copy the sheet with the code in it and send #2 Workbook to someone else in the office. When they click on the button to run the macro, it says it can't find the file. The code is below, but I don't think it is anything in the code, it is trying to find the file that the code was orginally in. Surely a code will run without having to have the orginal workbook tied to it.... If I run this code on Workbook #2 on my computer, it will open Workbook #1 and then it will run it fine. If I delete Workbook #1, then the code won't work. Help....

Sub Remi(
Application.ScreenUpdating = Fals
Password = "to
ActiveSheet.Unprotect Passwor
Range("C39:L44").Selec
Selection.Locked = Fals
Selection.FormulaHidden = Fals
Range("C39").Selec
Password = "to
ActiveSheet.Protect Password, True, True, Tru
Application.ScreenUpdating = Tru
End Sub
 
Hi Cecil,
Look at the button in Workbook 2. Change the macro attached to it to the
code in WB 2 instead of WB 1.
Regards,

Jean-Yves

Cecil said:
When I create a code in Workbook #1 it works fine. I copy the sheet with
the code in it and send #2 Workbook to someone else in the office. When they
click on the button to run the macro, it says it can't find the file. The
code is below, but I don't think it is anything in the code, it is trying to
find the file that the code was orginally in. Surely a code will run without
having to have the orginal workbook tied to it.... If I run this code on
Workbook #2 on my computer, it will open Workbook #1 and then it will run it
fine. If I delete Workbook #1, then the code won't work. Help.....
 
Yep, this is about as far as it gets. I guess this is just too complicated to solve. Maybe I am on the wrong discussion group, I don't know. Anyone know where I can go?

----- Cecil wrote: ----

Hi!
Yes, I know I can do that but I don't want to have everyone that I send this to have to manually change the macro. That would defeat having this thing run without needing to have someone mess with it. Why isn't there a way to have it point to the active sheet and not the workbook or the active workbook, making it so that it doesn't matter what the name of the workbook/sheet is? I am baffled, it seems this should be something very easy and I am just overlooking it.
Thank you.

----- Jean-Yves wrote: ----

Hi Cecil
Look at the button in Workbook 2. Change the macro attached to it to th
code in WB 2 instead of WB 1
Regards

Jean-Yve

Cecil said:
When I create a code in Workbook #1 it works fine. I copy the sheet wit
the code in it and send #2 Workbook to someone else in the office. When the
click on the button to run the macro, it says it can't find the file. Th
code is below, but I don't think it is anything in the code, it is trying t
find the file that the code was orginally in. Surely a code will run withou
having to have the orginal workbook tied to it.... If I run this code o
Workbook #2 on my computer, it will open Workbook #1 and then it will run i
fine. If I delete Workbook #1, then the code won't work. Help....
 
Hi Cecil,
Sorry , I left the office at 17:00 (CET).
I did put code in a sheet module in book A.
Added a command button on that worksheet and associate my sub with it,
then copied that sheet to a new book B.
No problem with me. How do call your code, what button do you use ?
Regards,
Jean-Yves


Cecil said:
Yep, this is about as far as it gets. I guess this is just too
complicated to solve. Maybe I am on the wrong discussion group, I don't
know. Anyone know where I can go?
----- Cecil wrote: -----

Hi!
Yes, I know I can do that but I don't want to have everyone that I
send this to have to manually change the macro. That would defeat having
this thing run without needing to have someone mess with it. Why isn't
there a way to have it point to the active sheet and not the workbook or the
active workbook, making it so that it doesn't matter what the name of the
workbook/sheet is? I am baffled, it seems this should be something very easy
and I am just overlooking it.
 
Hi Cecil,

I found the reason of your problem.
On a worksheet, you can create to kinds of button with macro association.
From the form toolbar OR from the VBA control toolbox that use ActivX
controls.
Use the second one, you will keep the correct association.
HTH
Regards
Jean-Yves


Cecil said:
Yep, this is about as far as it gets. I guess this is just too
complicated to solve. Maybe I am on the wrong discussion group, I don't
know. Anyone know where I can go?
----- Cecil wrote: -----

Hi!
Yes, I know I can do that but I don't want to have everyone that I
send this to have to manually change the macro. That would defeat having
this thing run without needing to have someone mess with it. Why isn't
there a way to have it point to the active sheet and not the workbook or the
active workbook, making it so that it doesn't matter what the name of the
workbook/sheet is? I am baffled, it seems this should be something very easy
and I am just overlooking it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top