Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically rebuild .exd-files when loading VBA

After updating Microsoft Office 2007 to Office 2010 some custom VBA scripts embedded in our software failed to compile with the following error message:

Object library invalid or contains references to object definitions that could not be found.

As far as I know, this error is a result of a security update from Microsoft (Microsoft Security Advisory 960715). When adding ActiveX-controls to VBA scripts, information about the controls are stored in cache files on the local hard drive (.exd-files). The security update modified some of these controls, but the .exd-files were not automatically updated. When the VBA scripts try to load the old versions of the controls stored in the cached files, the error occurs. These cache-files must be removed from the hard drive in order for the controls to load successfully (which will create new, updated .exd-files automatically).

What I would like to do is to programmatically (using Visual C++) remove the outdated .exd-files when our software loads. When opening a VBA project using CApcProject::ApcProject.Open I set the following flag:axProjectThrowAwayCompiledState.

TestHR(ApcProject.Open(pHost, (MSAPC::AxProjectFlag) (MSAPC::axProjectNormal | MSAPC::axProjectThrowAwayCompiledState)));

According to the documentation, this flag should cause the VBA project to be recompiled and the temporary files to be deleted and rebuilt. I've also tried to update the checksum of the host application type library which should have the same effect. However none of these fixes seem to do the job and I'm running out of ideas.

like image 253
aspartame Avatar asked Jun 11 '10 08:06

aspartame


1 Answers

I encountered this problem some times ago, and the recommended (and working) solution indeed was to delete all .exd files on the system drive. Obviously they are rebuilt whenever needed, so there is no need to programmatically trigger the rebuild process.

like image 175
Christoph Jüngling Avatar answered Oct 24 '22 00:10

Christoph Jüngling