LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Generating a drawing based on a cell Value (Repost Attempt)

I have an Excel workbook which places a picture in cell C5 based on a
drawing number in E56. Although my formula skills are pretty good, my
VBA
isn't. After much Googling the newsgroups I found the following code
(changed to suit my needs):

Sub test()
Dim s As String, i As Integer
s = "S:\Engineering\Drawings\Drawing Generator\Images"
ActiveSheet.Range("C5").Select
With Application.FileSearch
..NewSearch
..LookIn = s
..SearchSubFolders = False
..Filename = "*" & ActiveSheet.Range("E56") & ".EMF"
..MatchTextExactly = True
..Execute
For i = 1 To .FoundFiles.Count
ActiveSheet.DrawingObjects.Delete
ActiveSheet.Pictures.Insert (.FoundFiles(i))
Exit For
Next i
End With
End Sub

This works quite well...except for a couple nagging things that I can't
seem
to get a grasp of.

1. Our logo in B57 disappears everytime the above macro is executed. It

seems as if before the drawing is placed in C5, the screen refreshes.
The
only thing that I can see would be "ActiveSheet.DrawingObjects.Delete".
If
this is correct, how would I go about revising the code? I only want it
to
delete the picture in C5, but keep the logo in B57.

2. The macro is called "sheet10.test", I've made a hotkey (CTRL+d) to
run
the macro but would much rather have a button. Using the "Button"
command in
the Forms Toolbar, I made a button which works fine...once, then it
disappears. I think this is normal for the method I used to create the
button, but is there any way to keep the button on the screen for
additional
use, (i.e. generating a different drawing)?

Correcting the above two problems are of most importance. Soon after, I

would like to rename the macro "Generate Drawing" from "sheet10.test"
just
to keep things clean and simple. I would also like to create an error
message if the drawing does not exist in the folder it is searching in.

However, as mentioned above, items 1 and 2 are where I could use
immediate
assistance, any help would be greatly appreciated.


Many Thanks to a group which has already been alot of help!
Romy

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating a new list based on cell criteria JerryS Excel Worksheet Functions 1 March 29th 08 11:53 AM
macro to delete lines based on a value - Repost MarkT Excel Discussion (Misc queries) 2 October 19th 06 03:43 PM
Generating time based series Pete Charts and Charting in Excel 1 September 19th 06 08:28 AM
returning value based on font color-repost [email protected] Excel Programming 5 September 12th 06 01:57 AM
Generating a Userform based on a worksheet Glenn Excel Discussion (Misc queries) 0 March 4th 05 07:25 PM


All times are GMT +1. The time now is 02:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"