Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word97 - Removal of VBA

Status
Not open for further replies.

SHardy

Programmer
May 9, 2001
231
GB
I have a Word97 document in which I had written a VBA procedure to perform a specific task. This was just a one off run. I then removed all VBA code, as I didn't want to send the document out with macros in it.

However, despite having deleted all modules and all code, when the file is opened it still tells me that the document contains macros and asks if I want to enable/ disable.

Why is it doing this? And how can I stop it?

Thanks
 
Hi SHardy,

You must have left some vestige of something in there somewhere (perhaps just some whitespace) [smile]

In the Project Explorer in the VBE you should see something like this (when fully expanded):

[tt] Project(YourDocument)
Microsoft Word Objects
ThisDocument
References
Reference to Normal[/tt]

If there are any other elements (apart from references) you must delete them completely. Then select (double click) ThisDocument and make sure it is competely empty - Select All (ctrl+a) and Delete.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Had cleared everything out previously. However, double checked, using your post as reference, and there is definitely nothing there.

Still get the macro message though.
 
I wasn't doubting you but it is an easy mistake to make - just leaving something still there accidentally. If there really is nothing in the document is it perhaps based on a (non-normal) template which is triggering the message?

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
I had something similar before with an Excel97 workbook. It kept telling me that there was an Excel 4 macro, but I had only used VBA, and had removed all of that. I never did get to the bottom of it. I had to copy everything over to a new workbook.

Maybe I will need to do something similar here, and copy everything over to a new Word document?
 
Although you might not have any code modules left, you could still get this warning if your document still has any user forms, or code attached to the 'This Document' object.

Cheers
 
Nothing at all. All I did was add one module, in which I wrote one VBA procedure. This was to perform a one off specific task. Once I had run it, I deleted the module. I have been through several times to check that there is no code, no modules, etc. Also, I have not added form controls, let alone any forms. Nothing.

Like I said, I think I will just copy to a new (blank) document. This should get around the problem, rather than solving it.

Thanks for your comments.
 
Could you send me a copy of the document if it's not confidential? - (my handle here) at VBAExpress dot com

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
I had the same friggin problem recently. So I came back the next day and as Tony has said here, I went in side and removed the module that I had temporarily added.

NOW I DONT GET THE ENABLE/DISABLE MACRO MSG AGAIN!

HTH

-regards
Ashank
 
Tony,

Contents are confidential. However, I have taken a copy of the file and removed the entire contents. It still returns the message.

I will send this of to you now.

Thanks,
Simon
 
Thanks, Simon,

I now have a completely empty Word document with no code, no forms, no nothing which warns me about macros on opening. Very odd - I suspect it's just one of Word's little quirks and if copying the text to another document has solved the problem then it's probably best forgotten. I will haowever have a poke around in it over the weekend to see if I can discover anything - just out of interest.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Hi Simon,

I'm into things I don't know much about here. [smile]

I can clear the message but I don't understand enough of what I'm doing to know what other impact I may have (I don't appear to be affecting the empty document but it may be different with the content). At the moment I can't duplicate the problem.

Have you ever saved the document as HTML? And can you confirm that it is a Word 97 document.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Hi Simon,

I've done some more poking around and noticed that the document appears to have been recovered. I can only guess as to what state it was in when the abend happened and exactly how it was recovered but I wouldn't be surprised if that were the source of the problem. The document does have (at least the remains of) a VB Project (a UserForm?) - hence the warning - but it is not accessible via the VBE.

The document has an HTML Project, which is why I asked if you had saved it as HTML at any time, and it appears that the document and the HTML Project have got out of sync. The HTMLProject refers to an Edit-Time-Data file - this is where Word keeps elements of the document which don't translate into HTML (such as, but not limited to, a VB Project) so that they are available when the (HTML) document is opened for editing in Word. If you remove this reference in the Script editor (see below) the eventual contents of the edit-time data file are removed from the document and the VBProject and the warning are no more. If you do this, however, you may also lose various other (largely formatting) aspects of the document which may or may not be important to you (I can't tell as I don't have the document content). All that I can see are styles for footnote and endnote separators (which don't seem different from the default) which I would imagine you can fairly easily recreate.

To do the edit described above, go to Tools > Macro > Microsoft Script Editor (or press Alt-Shift-F11). In the main window, about 12 lines down you will see the following line:

[blue][tt] <[/tt][/blue][tt]link[/tt] [red][tt]rel[/tt][/red][blue][tt]=Edit-Time-Data[/tt][/blue] [red][tt]href[/tt][/red][blue][tt]="4864974_1_files/editdata.mso">[/tt][/blue]

Delete the line and quit the script editor, saving when prompted to do so.

Finally, I must stress my relative lack of knowledge in this area and a certain 'wing and a prayer' aspect to this 'fix' [smile]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
This is all rather interesting. For information, the history of the file is as follows:

1) I created a table in an Excel97 file.
2) Excel file was sent to external party for review.
3) Word file received back from external party. They had copied the table across to Word and then simply changed font colour in places to highlight certain texts. At this point I couldn't say exactly what they had done with the file. They were, however, just basic Word users. Not the sort to be writing macros or creating HTML files. Also, the file was received back in Word97 format, but I cannot guarantee that was the version of Word that they were using. At this, however, I was getting no messages.
4) I wrote a single VBA function in the "ThisDocument" module. I ran this function once and saved the file.
5) Realized that I had not deleted out the function, and that this would cause the macro message, and so re-opened file, deleted code, re-saved the file.

This is the point that we had got to. No code, but macro warning appears.

I cannot view Microsoft Script Editor in Word97, as described. I believe that this first appeared in Word2K.

From what you said, I don't know if it is possible that the external party could have accidentally saved as HTML. Realized their mistake, and then re-saved as Word97. If this had happened, once a VBA module had been added would this have caused this conflict? Even once the VBA code had been removed?

Presumably another fix would be to remove the HTML project entirely? Would need higher than Word97 to do this?

Thanks for your help with this.

Simon
 
Hi Simon,

It looks like the third party had Word 2003. I have been using 2000 and 2003 to look at it. I have just tried it in 97 and, yes. your options are rather limited. Saving it as RTF seemed to sort it out though. In a rush at present - will look further later.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top