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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lost VBA code

Status
Not open for further replies.
Jan 28, 2003
149
GB
Hi

Bit of a vague problem this one, but I hope someone can suggest something to help me go forward.

I've been asked to investigate a problem with 40-50 Word form documents, which have "lost" the VBA code. The documents are usually downloaded from an intranet. Other than someone deleting the VBA modules (which I think is unlikely given the number of documents) I can't think of any reason this would happen.

Can anyone shed any light how this might occur?

Cheers

B.M.
 
Yes we do, but it's very important I understand how this could happen to prevent it reoccuring. Getting the files back won't be a problem, but it's impractical to do this every two weeks.

B.M.
 
Our client is a bloody big organisation (I'd better not say who), so you can't discount someone with a grudge.

I've just tried opening a "working" template (don't think I mentioned originally the files are .dot)

I unprotected the document and added a msgbox to the AutoOpen code. I've then saved the file to a different name (in order that I don't overwrite the working version) but still a .dot file, and then closed Word (2000). It asked me if I wanted save changes to the original .dot file, to which I said no.

I've then opened the new version, and low and behold - there's no VBA code there!

Does this match what you would expect to happen? I'd have thought if you save changes to a new template file, it would keep the VBA modules.

B.M.
 
Have you trawled through the VBA modules for anything that looks odd...?

The following is an example of what you may find;

Code:
Workbooks(xlfile).VBProject.VBComponents.Remove "Module1.bas"

Hope this helps.


Leigh Moore
Solutions 4 MS Office Ltd
 
I had a problem like this one time, I think, not sure if this is any help but from what I can remember the document in my case and excel one was saved as a early version of the excel(5.0 or close) when this happened it removed the VBA code behind it. this might be the cause but it hard to say. If someone accidentally selected all the files a opened them like this and then saved them(somehow- users can do the unthinkable sometime). this might account for the loss of information.

 
OK - for reference I think I have the answer. It's difficult to confirm this, since the user in question is on holiday today.

One of the departments is changing name, and we suspect that the user in question has been tasked to make sure these forms reflect the name change (ie change logos and appropriate text both in the document and the VBA modules). The user has gone through and done all this, and then save the file as xxx_ver2.dot. Once done she's archived the originals and renamed the new files (why she didn't overwrite in the first place, I don't know, but nevertheless I'd have expected this method to work regardless).

In short - if you make changes to word files with VBA, don't do a Save As, because it won't save the VBA module.

Thanks for all your help.

B.M.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top