Thursday, March 24, 2011

How to make Office 2003 Macro works in Office 2010

So you upgrade to office 2010? Enjoy the great interface? But suddenly, you find your Word Macro that were created on Word 2003/2007 doesn’t work anymore, you get some errors like this: “Compile error: Can’t find project or library”



Basically, it happens because you are missing some OCX file, typically, they are MSCAL.OCX (Microsoft's ActiveX Calendar Control) and mscomct2.ocx(Microsoft Windows Common Controls). Follow below steps, most of your word and excel macro should work:
1. Get the OCX files: you can get mscomct2.ocx from Microsoft website: http://activex.microsoft.com/controls/vb6/mscomct2.cab or http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=25437d98-51d0-41c1-bb14-64662f5f62fe, but not MSCAL.OCX. Of course you can download from other sources, but I would recommend you install office 2003 pro in a spare computer or a VM, then copy this file.

2. Copy these 2 OCX files to c:\windows\system32 (if your OS is 32 bit) or C:\Windows\SysWOW64\ (if your OS is 64 bit).

3. Register these 2 OCX files:
For 32 bit OS:
regsvr32 /s C:\Windows\ system32 \mscomct2.ocx
regsvr32 /s C:\Windows\ system32 \MSCAL.OCX

For 64 bit OS:
regsvr32 /s C:\Windows\SysWOW64\mscomct2.ocx
regsvr32 /s C:\Windows\SysWOW64\MSCAL.OCX

4. Put your file location into trust location:
1). For Word 2010:Click menu “File”-> “Options” -> Trust Center, click "Trust Center settings" button, select "Trusted Locations"; click "Add new location..." button, add your file location there, you may also select "Subfolders of this location are also trusted".

2). Same as Excel 2010

 5. Ok, open your Word/Excel macro file, works? No? oh, you are using office 2010 64 bit, unfortunately, Microsoft said they won’t provide 64bit version of mscomct2.ocx even its name is “Common Controls”.


If your word/excel macro files are shared with other users, you need to implement this change silently to other computers. Here is what I’ve done:

1. Create a folder that includes these file: MSCAL.ocx, mscomct2.ocx, a .bat file, a .reg file:

2. The .reg file (Change “C:\\test\\” to your actual folder):

Windows Registry Editor Version 5.00

 [HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Word\Security\Trusted Locations]

 "AllowNetworkLocations"=dword:00000001

 [HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Word\Security\Trusted Locations\Location9]

 "Path"="C:\\test\\"

 "AllowSubfolders"=dword:00000001

 "Description"=""

 "Date"="2/8/2011 11:19 AM"

  
[HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\Security\Trusted Locations]

 "AllowNetworkLocations"=dword:00000001

 [HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\Security\Trusted Locations\Location9]

 "Path"="C:\\test\\"

 "AllowSubfolders"=dword:00000001

 "Description"=""

 "Date"="2/8/2011 12:36 AM"



3. The .bat file(change SysWOW64 to system32 if you are using 32bit OS):

regedit.exe /s .\TrustP.reg
copy .\mscomct2.ocx C:\Windows\SysWOW64\ /Y
regsvr32 /s C:\Windows\SysWOW64\mscomct2.ocx
copy .\MSCAL.OCX C:\Windows\SysWOW64\ /Y
regsvr32 /s C:\Windows\SysWOW64\MSCAL.OCX


Now you can push the change using your patch system like SCCM.



No comments:

Post a Comment