Macros Run Amuck!

D

Dax Arroway

HELP please! I had a template that worked pretty good but I wanted to add a
spell check macro and a print macro to, which I did, and it works great but
now, when I open documents that were created from the old template, the one
without the macros, it somehow gets referenced to the new template, with the
macros, and won't work. For example, I go to print it and the VB Debugger
comes up. If I disable the macros and hit print, an error comes up saying
that the macros are turned off and it won't print it. Yes, because the macro
that it's trying to run references a button (that the macro hides) which
isn't on the old forms. I'm not the expert of VB and my understanding of it
is limited so if you'd be as English in your answers as you coud I sure would
appreciate it. This only happens in documents that used the older version of
that template. There weren't macros in them before, but now when I go to
open them I'm asked if I want to run macros. It's weird! Please help.

Does anyone have a clue as to what's going on and how to get it to knock it
off??
Any help is greatly appreciated. Much thanks in advance!!!
--Dax
 
D

Doug Robbins - Word MVP

You should change the name of the new template so that the old documents
create a reference to the correct (old) template when they are opened. In
the case of the documents, created from the new template. After changing
the name of the new template, you will need to open the documents that were
created from it and then attach the template with the new name to those
documents so that the features in the new template are available to those
documents.

Alternatively, you will need to modify the code in the template so that it
properly handles the errors that occur when and old document is opened.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
D

Dax Arroway

Again Doug, you're the man! Thank you so much. What I actually did was to
create a copy of the modified file and gave it another name, then opened the
older version of the modified file and deleted the macros. I left it there
and that worked. I deleted it too and it still worked so we're good. There
are instaces however, where I'd need to add some code that could handle this
error. The template sits on the server and has a generic name, for example,
Inatake.dot, which people access and have shortcuts to. This file every now
and then gets updated. In ordr to not 'break' everyones links and shortcuts
(which drives IT NUTS! hee hee), we keep the filename and replace it with the
updated file.

I'm wondering if you by chance might share some code which might get over
the error message? The macro is a print macro which hides a macrobutton.
So, documents without that macro button throw the errors. It's a runtime
error and I don't know specifically what it says but here's the code for the
"hiding the button".

Sub FilePrint()
With ActiveDocument
.Bookmarks("AddProblemButton").Range.Font.Hidden = True
Dialogs(wdDialogFilePrint).Show
.Bookmarks("AddProblemButton").Range.Font.Hidden = False
End With
End Sub

Sub FilePrintDefault()
With ActiveDocument
.Bookmarks("AddProblemButton").Range.Font.Hidden = True
.PrintOut Background:=False
.Bookmarks("AddProblemButton").Range.Font.Hidden = False
End With
End Sub

Any help?
 
D

Doug Robbins - Word MVP

You could add some code to the (an) autonew macro in the template that adds
a document variable to each document that is created with the new template.
Then in the code that is causing the error, you could include code to access
the value assigned to that variable. If the variable does not exist (which
it would not in documents created from the old template, you will get a
Run-time error '5825' By using error trapping for that error, you can
prevent the other error message from appearing.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

Dax Arroway said:
Again Doug, you're the man! Thank you so much. What I actually did was
to
create a copy of the modified file and gave it another name, then opened
the
older version of the modified file and deleted the macros. I left it
there
and that worked. I deleted it too and it still worked so we're good.
There
are instaces however, where I'd need to add some code that could handle
this
error. The template sits on the server and has a generic name, for
example,
Inatake.dot, which people access and have shortcuts to. This file every
now
and then gets updated. In ordr to not 'break' everyones links and
shortcuts
(which drives IT NUTS! hee hee), we keep the filename and replace it with
the
updated file.

I'm wondering if you by chance might share some code which might get over
the error message? The macro is a print macro which hides a macrobutton.
So, documents without that macro button throw the errors. It's a runtime
error and I don't know specifically what it says but here's the code for
the
"hiding the button".

Sub FilePrint()
With ActiveDocument
.Bookmarks("AddProblemButton").Range.Font.Hidden = True
Dialogs(wdDialogFilePrint).Show
.Bookmarks("AddProblemButton").Range.Font.Hidden = False
End With
End Sub

Sub FilePrintDefault()
With ActiveDocument
.Bookmarks("AddProblemButton").Range.Font.Hidden = True
.PrintOut Background:=False
.Bookmarks("AddProblemButton").Range.Font.Hidden = False
End With
End Sub

Any help?
 

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