A very visually basic question

W

Wallace

I want to put a macro in a template I have (Word 2003). I open the template
and go to Tools>Macros>Record Macro. I assign the macro a name and tell Word
I want to store it in this template. Then I record the macro. I save and
close the template.

I open a new document from that template and sure enough, there's the text
of my macro, just as I typed it. It doesn't do anything — it just sits there
in the template, for all the world to see.

What (or should I say how many things) have I done wrong?
 
C

Charles Kenyon

First, don't use macros for repeating text. Its the wrong tool. Use AutoText
or AutoCorrect.

It sounds like you saved your template with the text showing. When you
create a new document based on a template, it will show whatever text is in
the template.

http://word.mvps.org/FAQs/MacrosVBA/VBABasicsIn15Mins.htm
http://word.mvps.org/FAQs/Customization/AutoCorrect.htm
http://word.mvps.org/FAQs/Customization/AutoText.htm

For more on the different kinds of templates, tabs on the file new dialog,
and locations of templates folders see
http://addbalance.com/usersguide/templates.htm.

I suspect that you have moved from Word Perfect, where macros are used to
repeat text. If so and if you would like some suggestions on making Word
easier to use, reply back.
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
T

Tony Jollans

Nothing in your description of what you have done mentions typing anything
so what do you mean when you say that the text of your macro is "just as I
typed it"?
 
W

Wallace

Okay, here is what I want to do. I want to create a template from which
documents will open to Track Changes "Final" rather than "Final Showing
Markup."
I have attempted to load this simple macro into the template:

Sub AutoOpen()
'Change Tracked Changes to Final View
With ActiveWindow.View
.ShowRevisionsAndComments = False
.RevisionsView = wdRevisionsViewFinal
End With
End Sub

As I mentioned, now when I open a document based on this template, the text
of the macro appears, but the Display for Review Window still shows "Final
Showing Markup."

So I need to have the macro *execute* when the document opens, not sit there
in the document itself, staring me in the face! Of course, when I go to the
macros library and run this macro from there, it works. But what's the point
of that? I can do the same thing by clicking the down arrow and changing the
view in the Track Changes window.

Anyway, that's my problem, and I appreciate those of you who have offered
suggestions.
 
T

Tony Jollans

Such a macro ought to work. Where have you put it?

I'm rather confused by what you say (that it is in the document) but you
mention that you recorded it so it should be in a module (probably
"NewMacros") in your template - or is it in Normal.dot?
 
W

Wallace

Tony:

It's in Normal.dot.

But now I have a new problem. When I attempt to run it, I get error message
#91: "Object variable or With block variable not set." I thought the With ...
End With block was properly defined, but VBA seems to disagree.
 
T

Tony Jollans

If you want it to run when documents based on a particular template are
opened, it must be in that template. If it's in Normal it will run when
documents based on Normal are opened - not documents based on other
templates.

Create a new module in your template and move the code into that.

Not sure about your error - did you have a document open at the time?
 
B

Barry Schwarz

I want to put a macro in a template I have (Word 2003). I open the template
and go to Tools>Macros>Record Macro. I assign the macro a name and tell Word
I want to store it in this template. Then I record the macro. I save and
close the template.

I open a new document from that template and sure enough, there's the text
of my macro, just as I typed it. It doesn't do anything — it just sits there
in the template, for all the world to see.

What (or should I say how many things) have I done wrong?

I think you need to create a template, open a DOCUMENT from that
template, and then record your macro and save it in the template.


Remove del for email
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top