Solved

Macro Created in 2003 upgaraded to 2007

Posted on 2009-07-14
10
317 Views
Last Modified: 2012-05-07
We recently updated to office 2007 from office 03. We had a macro to add a text box as a title. The macro now only works in .dot files. It errors out in .doc. We need it to work on .dot and .doc files. Any help?
Sub topictag()
'
' topictag Macro
'
'
    ActiveDocument.AttachedTemplate.BuildingBlockEntries("tag").Insert Where:= _
        Selection.Range, RichText:=True
        
End Sub

Open in new window

0
Comment
Question by:directpointe
[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
  • 2
10 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 24852318
Hello directpointe,

In 2007 macro enabled files have to be .docm.

If you want it to work in a .doc then ensure it is saved as type word 97 compatible .doc

Regards,
Chris
0
 
LVL 1

Author Comment

by:directpointe
ID: 24852734
The macro is just saved as a .txt from what i can see.
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 24852808
The macro is saved as part of the document.  IN the VBE it appears as text yes but the code is in a code module.  In 2007 files of type .doc are macro FREE, and must be saved as type .docm or as I said earlier as a word 97/2003 format as .doc.  Th eimportant point though is teh native word 2007 .doc file will not have any macros in it.

If the macro is saved elsewhere then that is a different matter so where do you run the code from?

Chris
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
LVL 76

Expert Comment

by:GrahamSkan
ID: 24854279
Sorry,

That macro couldn't have worked in Word 2003. The template object did not have

   BuildingBlockEntries  

as a property or a method.

0
 
LVL 1

Author Comment

by:directpointe
ID: 24854418
the document is saved as a 2003 format .doc- not anything fancy from 07(docx or docm). Would the import of the macro from 03 to .txt to office 07 macro cause this?
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 24856498
>>> Would the import of the macro from 03 to .txt to office 07 macro cause this?

POtentially yes

1.IMport of document text then yes the macro is wiped out, (ignored as such)
2. Import of the macro text and posting into a word 2007 document code module then unless the file is saved as 2003/97 compatible or .docm then the macros will again be non existant.

WHat happens in more detail during the cope?

Chris
0
 
LVL 1

Author Comment

by:directpointe
ID: 24898124
Ok so i got more information. They are just using the dev toolbar to create the macro step by step. On a few machines this has worked fine. Others it gives the error message. I don't understand how it would work in a template file (.dot) and not in the .doc file. Unless they create macro's differently?
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 24898228
What is the error message?
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 25429034
directpointe

So far everything I understand you to say hinges on the fact that you need the macro enabled option in 2007 of saving as either .docm or 2003 .doc.

In regard to the error mesage then as Graham asked some info on the message would potentially help understanding of the issue.

Chris
0
 
LVL 1

Author Closing Comment

by:directpointe
ID: 31603375
New question more important
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.

691 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