How To: Assign a Macro to a Button or Shape
来源:互联网 发布:中国电信天翼wifi网络 编辑:程序博客网 时间:2024/05/22 00:38
Quoted from: http://peltiertech.com/WordPress/how-to-assign-a-macro-to-a-button-or-shape/
In recent posts, I’ve discussed recording macros, fixing recorded macros, and even using someone else’s macros. To run a macro, you have a few choices.
- Tools menu > Macro > Macros, select the Macro, and click Run
- Shortcut Key combo Alt+F8, select the Macro, and click Run
- Run Macro button on the Visual Basic toolbar, select the Macro, and click Run
- Click in the macro with the mouse and press F5
None of these techniques are particularly elegant, and you wouldn’t want to email a file with a few macros to a colleague and tell them, “Okay, go to the Tools menu, select Macro, then select Macro, then click on MyFirstMacro in the list, and click Run.” It would be nice to just tell them, “Click the First Macro button.”
You can assign a macro to a few types of objects:
- Forms Menu Button or Shape
- ActiveX Button
- Menu or Toolbar Button
In this post we’ll look at using a Forms menu button to run our macros. We’ll use this simple macro for our example.
Sub HelloWorld() MsgBox "Hello, World! ", vbExclamationEnd Sub
When it is run, we see a simple message.
Forms Menu Controls
First make the Forms toolbar visible. Like so many other things in Excel, there are several ways to accomplish this.
- Tools menu > Customize > Toolbars tab, check the box in front of Forms
- View menu > Toolbars, select Forms from the list
- Right click on the menu and toolbar area, choose Forms from the list
The Forms toolbar will appear.
Select the Button button, then draw a rectangle in the worksheet where you want to place the button (you can move and resize it later). The Assign Macro dialog pops up with a list of macros in the active worksheet for you to select from.
Select a macro and click OK, or Cancel (you can select a macro at a future time). You can edit the text of the button after you dismiss the dialog, or right click on the button any time.
You can assign a macro to any of the Forms toolbar controls.
Shapes
You can assign a macro to any shape (including any chart) on a worksheet. Right click on the shape, choose Assign Macro, and follow the steps above.
Read more: http://peltiertech.com/WordPress/how-to-assign-a-macro-to-a-button-or-shape/#ixzz0jw33qWlG
- How To: Assign a Macro to a Button or Shape
- How To: Assign a Macro to an ActiveX Control
- How to add a button to PreferenceScreen
- How to Dynamically Slice a Convex Shape
- How to click a link / button implemented as a div or span element with WebDriver
- How to programmatically click a WPF button
- How to rename a VOB or view
- Something About C++ Macro(a Macro to print macro)
- How to convert a date to internal or external format?
- How do I autosize a button to fit its text
- How to Create a Slick and Clean Button in Photoshop
- How to build a nice Hamburger Button transition in Swift
- How to bring a subView to the front a UIView OR toBack a UIView
- Cannot assign a TFont to a TFont
- Cannot assign a TFont to a TFont!!
- cannot assign a tfont to a tfont
- How to programmatically assign a SkinID to a control while using a master page in ASP.net 2.0
- [Cexpert-002] How to assign default values to fields/members of a struct?
- MFC消息映射机制
- fseek()函数的说明
- Struts第三天
- 飞信消息管理器2010 0.1
- linux常用的简单命令(一) ls、pwd、cd、cat/more、grep
- How To: Assign a Macro to a Button or Shape
- 庆清明节
- matlab print
- HtmlParser简介
- outb_p() 函数、outb函数与outb指令
- Linux下的硬件驱动——USB设备
- 通过AIDL调用Service
- Log4j 配置
- 买个上网本