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

How to decompile VBA in Word doc

Status
Not open for further replies.

paradiso

Programmer
Apr 18, 2002
60
US
Friends,

Is it possible to decompile the VBA code behind a Word document? I tried the simple '/decompile' command switch but it did not work.

many thanks,
p
 
What is your meaning of decompile the VBA code ?
 
If you're thinking of achieving the same as through the Access /decompile switch, I'd say the easiest is probably to export and remove the modules and userforms, then import them again.

Roy-Vidar
 
When I use VBA with MS Access, I can decompile and recompile the code by adding a /decompile command switch to the command line in a shortcut (or I guess you could do it in the Start/Run window as well). This has the effect of cleaning up the code, and often reduces the file size considerably.

My document size has increased a lot since I've added a bunch of code, and I notice that previously deleted or renamed ActiveX controls still appear in the object box in the upper left of the VBA Editor, even though they have ceased to exist on the form. They don't show up in the Properties drop-down window, so I'm not suspecting they are lurking somewhere, hidden.

Is there a way to firm up or repair this code?
 
Installed Code Cleaner but got this msg:

Programmatic access to Visual Basic Project is not trusted.

I am following the instrutions I'm finding to move the code to a clean document, and will keep my ear open to other suggestions. If I succeed, I'll post the results.

p
 
Programmatic access to Visual Basic Project is not trusted
Check all the tabs of your security options window.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Curious. I got the Code Cleaner to run by checking the appropriate box (allow access to VBA project) in the Security window. However, I don't see an effect after the recompile/save. The file size is identical and the phantom control references are still there.

In a copy of the doc I deleted all the code from the module I use (ThisDocument) and found that the file size is still over 700 KB. It is over 900 KB with the code there. I'm hesitant to go on testing the export/import instructions because

a) the instructions refer to operations on a template. This is not a .dot, just a .doc

b) the instructions refer to other modules. My code is all in ThisDocument

c) Code Cleaner did leave the project uncompiled, so it must have done something. Perhaps there is nothing else I can do.

I'm open to suggestions,
p
 
My code is all in ThisDocument
The CodeCleaner can nothing for you in this case, sorry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top