ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro confusion (https://www.excelbanter.com/excel-programming/410376-macro-confusion.html)

BillE

macro confusion
 
I have buttons on my spreadsheet that run macros no problem.

I copied the spreadsheet to a different location on the same computer, and
now when I click a button in the copy to run a macro, i get the error:
"A document with the name messed_up.xls is already open. You cannot open
two documents with the same name etc."

But NO other spreadsheet is open.

I can fix this by relinking the button to the macro in the copy it is
supposed to run and it works fine again.

However, I don't understand what is happening. Are the buttons pointing to
macros in the spreadsheet in the original location instead of the copy?
When the macros run, are they trying to open the original spreadsheet and
hence the error?

On this hypothesis, I changed the name of the copy to messed_upMore.xls.
Now when I click the button to run the macro in messed_upMore.xls, I get the
error
"messed_up.xls could not be found. Check the spelling of the file name etc."

I hope somebody can explain this or refer me to a resource which will
explain it. I have searched google but only found the clue about relinking
the macros, with no explanation.

Thanks
Bill



Dave Peterson

macro confusion
 
You could reassign the macros to the new workbook.

But it may be easier to replace the buttons from the Forms toolbar with
commandbuttons from the control toolbox toolbar.

The code would move from a General module into the worksheet (doubleclick on the
button while in design mode and you'll see the click event).

And you may have to modify your code a bit.

This is one of the good things about using the Commandbuttons from the control
toolbox toolbar--there's no macro assignments to get messed up.

BillE wrote:

I have buttons on my spreadsheet that run macros no problem.

I copied the spreadsheet to a different location on the same computer, and
now when I click a button in the copy to run a macro, i get the error:
"A document with the name messed_up.xls is already open. You cannot open
two documents with the same name etc."

But NO other spreadsheet is open.

I can fix this by relinking the button to the macro in the copy it is
supposed to run and it works fine again.

However, I don't understand what is happening. Are the buttons pointing to
macros in the spreadsheet in the original location instead of the copy?
When the macros run, are they trying to open the original spreadsheet and
hence the error?

On this hypothesis, I changed the name of the copy to messed_upMore.xls.
Now when I click the button to run the macro in messed_upMore.xls, I get the
error
"messed_up.xls could not be found. Check the spelling of the file name etc."

I hope somebody can explain this or refer me to a resource which will
explain it. I have searched google but only found the clue about relinking
the macros, with no explanation.

Thanks
Bill


--

Dave Peterson

BillE

macro confusion
 
So, when I assign a macro to a button, it actually remembers the path to the
workbook where the macro is located?
And if I move the workbook to another location, it still tries to find the
macro at the original location?
Is there no way to specify that the macro should always be run from the
current workbook?

I appreciate your suggestion about using the control toolbox - however, I
think I read that there can be a problem because the control toolbox buttons
retain focus, unlike the forms toolbox buttons. Have you encountered this?

Thanks for your help!
Bill


"Dave Peterson" wrote in message
...
You could reassign the macros to the new workbook.

But it may be easier to replace the buttons from the Forms toolbar with
commandbuttons from the control toolbox toolbar.

The code would move from a General module into the worksheet (doubleclick
on the
button while in design mode and you'll see the click event).

And you may have to modify your code a bit.

This is one of the good things about using the Commandbuttons from the
control
toolbox toolbar--there's no macro assignments to get messed up.

BillE wrote:

I have buttons on my spreadsheet that run macros no problem.

I copied the spreadsheet to a different location on the same computer,
and
now when I click a button in the copy to run a macro, i get the error:
"A document with the name messed_up.xls is already open. You cannot open
two documents with the same name etc."

But NO other spreadsheet is open.

I can fix this by relinking the button to the macro in the copy it is
supposed to run and it works fine again.

However, I don't understand what is happening. Are the buttons pointing
to
macros in the spreadsheet in the original location instead of the copy?
When the macros run, are they trying to open the original spreadsheet and
hence the error?

On this hypothesis, I changed the name of the copy to messed_upMore.xls.
Now when I click the button to run the macro in messed_upMore.xls, I get
the
error
"messed_up.xls could not be found. Check the spelling of the file name
etc."

I hope somebody can explain this or refer me to a resource which will
explain it. I have searched google but only found the clue about
relinking
the macros, with no explanation.

Thanks
Bill


--

Dave Peterson




Dave Peterson

macro confusion
 
You could reassign the macro to the button each time you open the workbook and
remove any doubt how you think things should work.

And there was a problem with xl97 (changing the .takefocusonclick property to
false removed the problem).

BillE wrote:

So, when I assign a macro to a button, it actually remembers the path to the
workbook where the macro is located?
And if I move the workbook to another location, it still tries to find the
macro at the original location?
Is there no way to specify that the macro should always be run from the
current workbook?

I appreciate your suggestion about using the control toolbox - however, I
think I read that there can be a problem because the control toolbox buttons
retain focus, unlike the forms toolbox buttons. Have you encountered this?

Thanks for your help!
Bill

"Dave Peterson" wrote in message
...
You could reassign the macros to the new workbook.

But it may be easier to replace the buttons from the Forms toolbar with
commandbuttons from the control toolbox toolbar.

The code would move from a General module into the worksheet (doubleclick
on the
button while in design mode and you'll see the click event).

And you may have to modify your code a bit.

This is one of the good things about using the Commandbuttons from the
control
toolbox toolbar--there's no macro assignments to get messed up.

BillE wrote:

I have buttons on my spreadsheet that run macros no problem.

I copied the spreadsheet to a different location on the same computer,
and
now when I click a button in the copy to run a macro, i get the error:
"A document with the name messed_up.xls is already open. You cannot open
two documents with the same name etc."

But NO other spreadsheet is open.

I can fix this by relinking the button to the macro in the copy it is
supposed to run and it works fine again.

However, I don't understand what is happening. Are the buttons pointing
to
macros in the spreadsheet in the original location instead of the copy?
When the macros run, are they trying to open the original spreadsheet and
hence the error?

On this hypothesis, I changed the name of the copy to messed_upMore.xls.
Now when I click the button to run the macro in messed_upMore.xls, I get
the
error
"messed_up.xls could not be found. Check the spelling of the file name
etc."

I hope somebody can explain this or refer me to a resource which will
explain it. I have searched google but only found the clue about
relinking
the macros, with no explanation.

Thanks
Bill


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 07:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com