UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Edit Discussion
> Access Custom Right-click Menu    
Access Custom Right-click Menu

Contents

Introduction

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:
Image:RightClickMenu.png

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.
2. Download the attached zip file.
       Click to download the zip file
3. Extract the zip file
4. Place the file "ZipIt.vbs" in the path:
       C:\Windows\System32
5. Open the text file to do the following edits:
6. Find and Replace all "Access.Application.14" to "Access.Application.XX" and "Office14" to "OfficeXX" where the XX is your currently installed version of Acces:

Full Name Version
Access 2010 14
Access 2007 12
Access 2003 11
Access 2002 10
Access 2000 9
Access 97 8

NOTE: For Access 97 and prior, the Office directory did not have version suffix therefore, Find and Replace all "Office14" to "Office"
IMPORTANT: This assumes you used the default installation for Office. If you customized the install path for your Office, adjust the value(s) accordingly, to match your directory structure for multiple Office version installs.

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.
8. OPTIONAL: If you have multiple versions of Access installed, you may want to add additional entries to your text file to support "Open With Access XXXX" commands. Refer to Open With section for additional instructions.
9. Save the changes and change your text file's extension to a .reg file
10. Double click it to merge the changes into your registry.
11. Test the changes by right-clicking an Access file.

Detailed Explanations

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:

CODE
[HKEY_CLASSES_ROOT\.accdb]
"Content Type"="application/x-msaccess"
@="Access.Application.14"

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:

CODE
[HKEY_CLASSES_ROOT\Access.Application.14\Shell\Decompile\command]
@="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:

CODE
[HKEY_CLASSES_ROOT\Access.Application.14\shell\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

CODE
; Open with Access 2010

[HKEY_CLASSES_ROOT\Access.Application.14\shell\Open_with_Access_2010]
@="Open with Access 2010"

[HKEY_CLASSES_ROOT\Access.Application.14\shell\Open_with_Access_2010\command]
@="C:\\Program Files\\Microsoft Office\\Office14\\Msaccess.exe %1"
; Open with Access 2007

[HKEY_CLASSES_ROOT\Access.Application.14\shell\Open_with_Access_2007]
@="Open with Access 2007"

[HKEY_CLASSES_ROOT\Access.Application.14\shell\Open_with_Access_2007\command]
@="C:\\Program Files\\Microsoft Office\\Office12\\Msaccess.exe %1"
; Open with Access 2003

[HKEY_CLASSES_ROOT\Access.Application.14\shell\Open_with_Access_2003]
@="Open with Access 2003"

[HKEY_CLASSES_ROOT\Access.Application.14\shell\Open_with_Access_2003\command]
@="C:\\Program Files\\Microsoft Office\\Office11\\Msaccess.exe %1"
; Open with Access 97

[HKEY_CLASSES_ROOT\Access.Application.14\shell\Open_with_Access_1997]
@="Open with Access 1997"

[HKEY_CLASSES_ROOT\Access.Application.14\shell\Open_with_Access_1997\command]
@="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.
NOTE: Do NOT Find and Replace the Office directory for those portions. Doing so would defeat the objective.
3. Copy the modified text and paste to the text file and return to step 8 of the Quick Start Instructions.

Edit Discussion
Thank you for your support!
This page has been accessed 2,699 times.  This page was last modified 11:49, 2 May 2012 by Mark Davis. Contributions by BananaRepublic  Disclaimers