Hi Nirmall,
Very interesting question. The key to deleting the proper file is to have a naming convention and assign names to the shapes (pictures) as they are created.
For example (working code excerpt taken out of context):
See the attached file which uses one routine for all 8 searches. I also added the following capabilities which can be disabled:
a. 'Left Click' a picture to Enlarge the picture or restore an Enlarged picture to Normal size.
b. 'Added a caption at the bottom of each picture containing descriptive information.
c. Added a small YELLOW rectangle in the caption that will remove the picture wen 'Left Clicked'.
I also added a couple of utility routines in module ModUtilities that will:
a. Get the color of the active cell - useful for obtaining 'Color numbers'.
b. Display information about each Shape on the Sheet.
I tested the software using Excel 2003 and 32 bit Excel 2010.
In Excel 2003, I had problems with the Excel Window expanding beyond it's usual maximum size.
Reset the window size with command keys:
a. Press Alt+Spacebar. This displays the Control menu (even if you cannot see it).
b. Press the letter R; the Excel window is restored to its “in between” size.
c. Press Alt+Spacebar to again display the Control menu.
d. Press the letter X; the Excel window is maximized.
In Excel 2010, I had problems with VBA putting the pictures in the proper place. I corrected the problem by repeating the code that assigned picture Left and Top coordinates.
The 'Merge Areas' for Items 1, 5, 8 seemed to be one column too wide, and I reduced their size.
The following excerpt from the top of ordinary code module ModSearchDesign contains items that can be changed to modify the look and feel of the software:
How the software works:
a. I renamed your CommandButtons to ButtonSearch1' thru 'ButtonSearch8' and all were assigned to Macro SearchDesign().
b. Macro SearchDesign() identifies which CommandButton was pressed using Application.Caller. From the CommandButton name obtained, the Window Number 1 thru 8 is identified.
c. Appropriate data associated with the specific Window is obtained.
d. The picture (if available) is inserted in the appropriate Window. A caption containing data associated with the picture, and a small yellow rectangle shape are placed on the picture and all are grouped together.
It is a best practice to declare all variables. If you misspell a variable in your code, VBA will silently assume it is a Variant variable and go on executing with no clue to you that you have a bug. Go to the VBA development window, click Tools, Options, and check "Require Variable Declaration." This will insert the following line at the top of all new modules:
This option requires all variables to be declared and will give a compiler error for undeclared variables.
Lewis
Bookmarks