Clearing the Forms Cache Script

Outlook 2003 has some issues with custom forms. Although most issues with forms have been fixed in Office 2003 Service Pack 1 occasionally you still get confronted with “Outlook cannot open this form …” messages. You’re only solution; clear the forms cache and try again!

The forms cache can be cleared in 2 ways;

  • The short way can only be used when you have the Owner permissions or are working with a pst-file;
    Right-click the folder with the issues-> Properties-> tab Forms-> button Manage…-> button Clear Cache
  • The long way must be used when you for instance only have “Read” permissions on a Public Folder;
    Tools-> Options-> tab Other-> button Advanced Options…-> button Custom Forms…-> button Manage Forms…-> button Clear Cache

So clearing the forms cache is quite a longwinded process. This might be OK if it just happens every now and then but when you are for instance developing a lot of forms this can be quite time consuming. If you need to clear the cache quite often you can also use the script below to quickly clear it. Copy the code to Notepad and then save it as filename.vbs or download it here. When you execute the script you might get a warning of your virus scanner. This is because the script deletes the forms cache of your hard disk. Allow the activity once and the script will finish.

'Close Outlook forcefully
WScript.Echo "Close Outlook and press OK"

'Close Outlook forcefully
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'outlook.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next

'Set Profile Path
Set oShell = CreateObject("WScript.Shell")
sCurrUsrPath = oShell.ExpandEnvironmentStrings("%UserProfile%")
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Verify whether the Forms Cache exists and delete it
If objFSO.FolderExists(sCurrUsrPath & "\Local Settings\Application Data\Microsoft\Forms") Then
WScript.Echo "The Forms Cache has been found and will be cleared."
Const DeleteReadOnly = True
objFSO.DeleteFolder(sCurrUsrPath & "\Local Settings\Application Data\Microsoft\Forms"), DeleteReadOnly
WScript.Echo "The Forms Cache has been cleared successfully. Start Outlook and check whether the form works now."

Else

WScript.Echo "Cannot find the Forms Cache. It has been cleared already. Start Outlook and check whether the form works now."

End If