1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Teacher needs help with Macros Word 2007

Discussion in 'Business Applications' started by meccagza, Nov 22, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. meccagza

    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 !
     
  2. WendyM

    WendyM Trusted Advisor

    Joined:
    Jun 27, 2003
    Messages:
    4,032
    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?
     
  3. meccagza

    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.
     
  4. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    5,947
    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.
     
  5. WendyM

    WendyM Trusted Advisor

    Joined:
    Jun 27, 2003
    Messages:
    4,032
    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?
     
  6. Sponsor

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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1027953