Hi Julie,
Thank you for the book recommendation. My background is in Java, C/C++, but
for this app my wish is to implement some quick and easy to maintain code
since I will not likely be the long term developer on this project.
OK... You first need to decide on what method you want to use to transverse the
folder structure and pick up the files. Office can work with Dir,
FileSystemObject (which requires making sure the Scripting Runtime library is
installed and activating a reference to it) or the Office FileSearch
capability. Most people I know work with Dir since it's reliable and doesn't
require any outside DLLs. To get information on how Dir works, type this into
the VBA Editor then press F1 to get to the Help. I think you'll find the
concepts familiar enough that you'll get on with no great problems. Try a
couple of examples until you're getting the list of files you expect.
In order to create the menu you need to work with CommandBars, which are part
of the Office object model (shared by most Office apps). I think you'll find
some basic information at word.mvps.org and other places on the web (do a
Google search, for instance). To create your own menu on the menu bar:
Dim menu as CommandBarPopup
Set menu = Application.CommandBars("Menu bar").Controls.Add('params here)
menu.Caption ="Caption"
Now you'll probably want to loop through the folders and files, creating
buttons as you go. To add a button that opens a file to the dropdown
Dim fileButton as CommandBarButton
Set fileButton = menu.CommandBar.Controls.Add('params)
fileButton.OnAction = "NameOfMacroToRunWhenClicked"
To add another "dropdown level", use a new control of the type CommandBarPopup
Note how a CommandBarPopup has a CommandBar property - this will NOT show up in
the Intellisense, but it's key to building the menu.
Since all the controls will basically run the same macro to insert a file, you
can store the full file path in the controls' Tag or Parameter property. In the
common macro:
rng.InsertFile FileName:=CommandBars.ActionControl.Parameter
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail
![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)