ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ChangeLink problem (https://www.excelbanter.com/excel-programming/416568-re-changelink-problem.html)

Peter[_63_]

ChangeLink problem
 
Hi Diddy,

I came across the same problem when executing a macro which uses the
ChangeLink command.
Executing through the Excel menu ("Extra"| Macro | Macro's |Execute")
gave no error but calling the macro from the _click event of a command
button gave the error you mentioned.

After a while I noticed that using the menu also gave an error when the
command button had the focus but not when a worksheet cell had the
focus.

For me, using Range("A1").Select before calling the macro solved the
problem.



So:

Sub CommandButton1_Click()
Call Macro_with_ChangeLink
End Sub

Results in an error


And:

Sub CommandButton1_Click()
Range("A1").Select
Call Macro_with_ChangeLink
End Sub

No problem at all.


Regards, Peter

*** Sent via Developersdex http://www.developersdex.com ***

Diddy

ChangeLink problem
 
Thanks for that Peter,

I've saved this with my snippets!

Cheers
--
Deirdre


"Peter" wrote:

Hi Diddy,

I came across the same problem when executing a macro which uses the
ChangeLink command.
Executing through the Excel menu ("Extra"| Macro | Macro's |Execute")
gave no error but calling the macro from the _click event of a command
button gave the error you mentioned.

After a while I noticed that using the menu also gave an error when the
command button had the focus but not when a worksheet cell had the
focus.

For me, using Range("A1").Select before calling the macro solved the
problem.



So:

Sub CommandButton1_Click()
Call Macro_with_ChangeLink
End Sub

Results in an error


And:

Sub CommandButton1_Click()
Range("A1").Select
Call Macro_with_ChangeLink
End Sub

No problem at all.


Regards, Peter

*** Sent via Developersdex http://www.developersdex.com ***



All times are GMT +1. The time now is 01:39 PM.

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