复制文件时将宏重新分配给命令按钮 [英] Re-assignment of Macro to Command button when copying file

查看:32
本文介绍了复制文件时将宏重新分配给命令按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在XL中,我有一个问题,当将源工作表复制到新工作簿中的目标工作表时,重新定义单选按钮的宏分配.

I have a problem in XL regarding redefining the Macro assignment of radio button when the source worksheet is copied to a Destination worksheet within a new workbook.

当我单击目标"工作表中的单选按钮时,它会尝试打开源工作簿",然后运行分配给该按钮的宏.

When i click on the radio button in the Destination worksheet, it attempt to open the Source workbook RATHER to run the macro assigned to the button.

我已经检查过,并且目标工作簿确实具有与原始源"工作簿相同的宏副本.但是,通过右键单击/分配单选按钮上的宏,我发现路径STILL指向源工作簿/工作表.

I have checked and the Destination workbook DOES indeed have identical copy of the macro, as the original Source workbook. However, by Right clicking / Assign Macro on the radio button, i find that the path STILL points to the source workbook/worksheet.

我在源"工作表中运行以下代码时尝试了该代码,但它不起作用.

I tried the following code while running it from the Source worksheet, but it does not work.

代码:

wbkDESTINATION.Sheets("1-Start").Select
ActiveSheet.Shapes("Option Button 1").Select
Selection.OnAction = "Sheet1.WEEKLY"

我很感谢您的建议,即如何修改最后的 Selection.OnAction 代码,以便XL知道从Destination工作表中选择它,而不是跳回到原始的源工作簿.

I would appreciate your suggestion, how to modify the last Selection.OnAction code so that XL knows to pick it from the Destination worksheet, instead of jumping back to the original source workbook.

谢谢

推荐答案

此更新已完成,但我将其发布给以后的求职者.

This is quite updated but I 'm posting it for future seekers.

我遇到了这个问题,因为我遇到了与上述问题完全相同的问题.最后,我找到了以下解决方案,并提示了如何从源工作表中删除连接(如果存在).

I run into this question as I had exactly the same problem as mentioned. Finally I 've found the following solution and got a hint on how to remove connections from the source-worksheet (if they exist).

https://www.thespreadsheetguru.com/blog/correcting-shape-assigned-macro-links-after-copying-worksheet-vba

这篇关于复制文件时将宏重新分配给命令按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆