Solved

Assign a macro to a button in a Word document

Posted on 2007-11-28
8
2,091 Views
Last Modified: 2012-05-05
I'm making a form in Word 2007. It's like a student CV. I have a macro that creates a new table if a student wishes to add more than one qualification. I can't find a way to put a button on the page for the students to click, so as to activate the macro to create the new table.
0
Comment
Question by:nz_witch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 17

Accepted Solution

by:
wobbled earned 125 total points
ID: 20372446
Use the insert field option and make that field a macrobutton.  You can select the macro you want from the list
0
 

Author Comment

by:nz_witch
ID: 20372488
Oh d'oh! I remember doing that ages ago in an old version of Word. I thought you could attach a macro to a button/auto shape, but I think I'm getting confused with Excel.

One thing I did discover today was the new Quick Part boilerplate gallery, which is going to make it so much easier to make a macro to create a table etc.

Do you mean the fields you can enter from the developer ribbon? I've been using the rich text one for students to click and enter their data - I'm not sure how to make those into a macrobutton. Will try tomorrow at work and get back to you.
0
 
LVL 17

Expert Comment

by:wobbled
ID: 20372519
Hi nz_witch, Excel is much easier with its buttons to assign a macro, but for a basic how to guide on inserting fields in office 2007 try this  http://www.uwec.edu/help/Word07/fields.htm

0
Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

 

Author Comment

by:nz_witch
ID: 20376926
OK, I added a field, 'Author', changed the text, how do I attach my pre-made macro to it?
0
 

Author Comment

by:nz_witch
ID: 20376974
Sorry, I see macrobutton is an entity on its own. I have attached my macro but the macrobutton disappears after it's clicked. I'll keep fiddling but I think it's nearly there. :)
0
 
LVL 17

Expert Comment

by:wobbled
ID: 20377125
Hi,

It shouldn't disappear after you click on it.

What you can do in Word 2007 is go to the developer tab, choose legacy controls.  Under there you will see a button object.  You can draw a button on your page.  Right click on the button and go to view code.  In here you can then just type call mymacro  where mymacro is the name of your macro.

Hope that helps
0
 

Author Comment

by:nz_witch
ID: 20377294
Thanks, I did get the macrobutton field going. It disappeared because I had my spacing up the wop and the table was placed over where the button was. :D That's sorted now.

I might go and try the legacy button, I looked at that yesterday but I wasn't sure how to run a macro from VB. As long as I can make it hidden so the student doesn't see it when it previews or prints.

Anyway, I know how to do it now, thanks to you, the rest is just fiddling to get it right.

Thanks for your help.
0
 
LVL 17

Expert Comment

by:wobbled
ID: 20380642
Not a problem, glad I could have helped and thanks for the points and grade
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question