Access Custom Right-click Menu
There are certain commands that Access developers may want to execute on more than one occasions. Some of the commands may be built-in but either are not easily accessible or do not behave in a desired manner. Decompile is an example of former - being undocumented, there is no UI mechanism to request a decompile of an Access file and it would have to be done via command line prompt. Backup is an example of latter, we do have a Backup command which also conveniently append a timestamp to the filename for a quick backup. However, when the procedure requires frequent backup of Access files that may be sizable, zipping them up is more desirable and would have to be done as a separate step.
One convenient option to manage those is to customize the right-click menu exposed in the Windows Explorer. The commands available for a given file format is governed by registry setting so it is possible to use a .reg file to enhance the right menu and thus achieve a result as shown:
Quick Start Instructions
IMPORTANT! Back up your registry prior to editing. While editing should not have detrimental effect, there is absolutely no guarantees or warranties with the modification! Proceed at your own risk!
1. Back up your registry.
NOTE: For Access 97 and prior, the Office directory did not have version suffix therefore, Find and Replace all "Office14" to "Office"
7. If you are using a 64-bit operating system and running 32-bit Access, find and replace "Program Files" to "Program Files (x86)". Otherwise skip the step.
The registry modification essentially involves modification of two things: file association and Shell subkeys of the content. We establish a file association with this following modification:
The effect is that when Windows explorer finds an .accdb file, it will match the menu that's enumerated under the Access.Application.14. The menu commands are enumerated under Shell subkey as here:
@="C:\\Program Files\\Microsoft Office\\Office14\\MSAccess.exe \"%1\" /DECOMPILE"
The "Decompile" subkey governs the caption that will be shown on the menu of Windows Explorer. The "command" key then must contain a valid command. You can pass in %1 to indicate a current selection from the Windows Explorer. Note that it is necessary to escape the %1 with quotes to handle Access files that has spaces or are in a path with spaces. Any command that you can execute in a command prompt can be placed here, provided that you reference an executable file. You can't execute commands on a script file but you can work around this by invoking WScript.exe or CScript.exe, referencing the script file and passing in the parameters, as demonstrated in the Backup command:
@="WScript C:\\\\Windows\\\\System32\\\\ZipIt.vbs \"%1\" //B //NoLogo //T:30"
Zipped Backup Script
There is no native command in Command Prompt to zip a file (there is a Compress command but it does something different), thus necessitating use of a VBScript file to provide a mean of zipping the file. The script also append a date/time in ISO format so that you can generate several separate backups from same file without having to manually rename the new zip file every time as is the case with built-in "Send To -> Compressed Folder" command. Currently it simply does zipping only but it may be modified to also do compact or decompile and also can be used for any other files, not just Access files.
Open With Access XXXX Command
NOTE: Generally speaking, it is recommended that multiple Office installations be avoided if at all possible. There are several additional issues that may cause problems with managing Access files in an environment with more than one Office installation.
To add "Open With Access XXXX" command, use the below snippet with the following instructions:
NOTE: If you have not done so, perform step 1-6 of Quick Start Instructions before performing the following steps
1. Select the section for which Access versions you have installed and wish to open with
; Open with Access 2010
@="Open with Access 2010"
@="C:\\Program Files\\Microsoft Office\\Office14\\Msaccess.exe %1"
; Open with Access 2007
@="Open with Access 2007"
@="C:\\Program Files\\Microsoft Office\\Office12\\Msaccess.exe %1"
; Open with Access 2003
@="Open with Access 2003"
@="C:\\Program Files\\Microsoft Office\\Office11\\Msaccess.exe %1"
; Open with Access 97
@="Open with Access 1997"
@="C:\\Program Files\\Microsoft Office\\Office\\Msaccess.exe %1"
2. Find and replace "Access.Application.14" with "Access.Application.XX" where XX matches the number you used from the step #6 in the Quick Start steps.
|This page has been accessed 7,200 times. This page was last modified 11:49, 2 May 2012 by Mark Davis. Contributions by BananaRepublic Disclaimers|