简体   繁体   English

无法在Excel中分配宏

[英]Can't assign macro in excel

I am having some trouble with macros in my excel workbook. 我在Excel工作簿中遇到了一些宏问题。 I have a couple of auto-shapes on one of my sheets which are grouped together for drawings. 我的一张纸上有几个自动形状,这些形状被组合在一起以用于图纸。 2 of these have macros assigned to them (as 'kitchen - 1.xls'!but59 and 'kitchen - 1.xls'!but60 ), but I can't seem to assign macros to the other 2 shapes. 其中2个具有分配给它们的宏(如'kitchen-1.xls'!but59'kitchen-1.xls'!but60 ),但我似乎无法将宏分配给其他2个形状。 I have tried right clicking on the shape, Assign Macro , select the macro that I wan to assign to, and then click Okay . 我尝试右键单击形状“ 分配宏” ,选择我想要分配的宏,然后单击“ 确定” But when I double check which macro it calls, it still calls Baseunits_fbase3_3_Click - it creates this new macro and I can't seem to force it to use my already written macro. 但是,当我仔细检查它调用哪个宏时,它仍然调用Baseunits_fbase3_3_Click-它创建了这个新宏,我似乎无法强迫它使用已经编写的宏。 Is there any other way to assign the macro that I need? 还有其他分配我需要的宏的方法吗?


EDIT: I am kind of hoping that there is perhaps a way to assign the macro via VBA, but I can't see any reference to that in the online VBA reference anywhere. 编辑:我希望有一种方法可以通过VBA分配宏,但是我在任何地方的在线VBA参考中都看不到对此的任何引用。 Does anyone know if this is possible? 有人知道这是否可能吗?

Okay, my solution to this (a bit of a hack, but it works) was to simply create a rectangle shape, give it no fill and no line, order it to the front, place it over the shape that the user has to click, and then assign the macro to this front shape. 好的,我对此的解决方案(有点小技巧,但是可以用)是简单地创建一个矩形形状,不给它填充和没有线,将其排列在最前面,将其放置在用户必须点击的形状上,然后将宏分配给该前部形状。

Still no idea why I can't assign the macro to the original shapes, though - there has been quite a few like that now. 不过,仍然不知道为什么我不能将宏分配给原始形状-现在已经有很多这样的东西。

EDIT: I worked out how to assign the macro - I had to select the group, and then also select each of the shapes in the group , and assign the macro to all these selected shapes. 编辑:我想出了如何分配宏-我必须选择组,然后还要选择组中的每个形状 ,然后将宏分配给所有这些选定的形状。 This seemed to work consistently, and was also necessary in a number of cases for porting to Excel 2007. 这似乎始终如一,并且在许多情况下也需要移植到Excel 2007。

I take it this is for Excel 2003?? 我认为这是针对Excel 2003的??

What you are doing sounds correct. 你在做什么听起来很正确。 It sounds like there is a problem with the Grouping. 听起来好像分组有问题。

You have two options: 您有两种选择:

  1. In Baseunits_fbase3_3_Click , call the 'kitchen - 1.xls'!but59 Baseunits_fbase3_3_Click中 ,调用“厨房-1.xls”!but59

  2. Delete all the objects in that group, and try again 删除该组中的所有对象,然后重试

The first option is a bit excessive and the second is a little drastic. 第一种选择有点过分,第二种选择有点过激。

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM