View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
jo77 jo77 is offline
external usenet poster
 
Posts: 6
Default Variable menu with single "on-action" procedure

Hi all,

I have created an Excel Menu (CommandBars, Type:=msoControlPopup)
(using Excel 2003). Let's call this menu: "Accounting". The menu
"Accounting" contains a sub-menu item, called "User Manuals".
When a user starts Excel, a module lists all files in a given path,
let's say C:\Accounting\UserManuals\ , as well the files of each sub-
directory of this path.
Each file found is put on a worksheet with following information:

Column G: Path which has been searched
Column H: Length of the path name
Column I: Hyperlink to the file
Column J: Name of the file (without path)

Then:
For each file found within C:\Accounting\UserManuals\ , a module adds
the name of the file to the sub-menu "User Manuals" (using a for…each
loop)
For each sub-directory within C:\Accounting\UserManuals\, the module
creates a sub-menu item within "User Manuals", and then adds the name
of each file found within the sub-directory to it (again using a
for...each loop).

So at the end, the Accounting menu could look like this:

Accounting
Balance Sheet - opens an Excel template, mentionned here just as
example
Currency Rates - opens an Excel template, mentionned here just as
example
User Manuals
Manual for currency rates.pdf - file located in C:\Accounting
\UserManuals\
Manual for xyz.pdf - file located in C:\Accounting\UserManuals\
Balance Sheet - sub-directory in C:\Accounting\UserManuals\
Manual for balance sheet.pdf - file in C:\Accounting\UserManuals
\Balance Sheet\
Manual for abc.pdf - file in C:\Accounting\UserManuals\Balance
Sheet\
Booking Manuals - sub-directory in C:\Accounting\UserManuals\
Manual for trades.pdf
Manual for dividends.pdf

Now my problem: I would like to write a single module to call, so that
when a user selects any of the menu items within "User Manuals" or
within a sub-menu of "User Manuals", I can activate the corresponding
hyperlink of the file stored on the worksheet.
Can anyone help or suggest me something?

I hope my explanation is clear (not really easy to explain), I'm quite
new in the VBA world and even less familiar with the menu procedures.
Thanks in advance for any help.