Teacher needs help with Macros Word 2007

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

meccagza

Thread Starter
Joined
Nov 21, 2011
Messages
2
I have been having problems with more than half my machines, some are laptops and some are networked desktop computers. I am having my students record macros for basic formatting. Half the tasks we try give us errors or simply don't complete (For example, if I center all the text, change the background color and add a page border, the background color simply won't change even though I can see it in the code). I have had a particular problem with inserting the student name into the header of the document. They need to be able to do this in particular because they are taking Cambridge Exams and might be asked to do it. The first line is the line of code that is highlighted and gives us errors:

ActiveDocument.AttachedTemplate.BuildingBlockEntries(" Blank").Insert_Where:=Selection.Range, RichText:=True
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
Welection.TypeText Text:="Student Name "

Please help !
 

WendyM

Retired Trusted Advisor
Joined
Jun 27, 2003
Messages
4,042
Hi meccagza,
Are you getting a runtime error message? If so, what does it say? And are you recording this macro or writing it from scratch?
 

meccagza

Thread Starter
Joined
Nov 21, 2011
Messages
2
We are recording the macro, I am not a programmer so I am not be able to write it from scratch. Sometimes we get a runtime error, and sometimes it just doesn't show up (the name in the header). When I go into debug the first line of code is highlighted. If you have any ideas or suggetions to make things work better, that would be great, we are just trying to use macros at this point for very simple page formatting and name insertion.
 

Keebellah

Hans
Trusted Advisor
Joined
Mar 27, 2008
Messages
6,641
I think posting a sample with the macro's will offer more information so that one of us can look at it.
Your information does not tell us anything.
 

WendyM

Retired Trusted Advisor
Joined
Jun 27, 2003
Messages
4,042
The problem is likely with the AttachedTemplate.BuildingBlockEntries. When you're recording, Word knows where to get those Building Blocks. But when you try to run it in an document, Word doesn't understand what the "attached template" is, so you have to tell it how to get to the Building Blocks. You can add several lines of code to try to get the macro working, but since you're not comfortable with modifying the code I think it would be simpler to create the Building Block and save it as a header that the students could just insert as needed. Does it have to be a macro?
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top