Is this possible?

  • Thread starter Thread starter TyeJae
  • Start date Start date
T

TyeJae

Ok... I have scanned into my computer all of the baseball cards that
collected during my youth. I have cropped all the cards to the sam
size and entered every card into a database that looks like this...

F1 = Qty
G1 = Name
H1 = Type
I1 = Value
J1 = Position (P)
K1 = Talent (number between 1 and 10)
L1 = Secondary Position
M1 = Year of Card
N1 = Quality of Card
O1 = Best Stat

Let's say Barry Bonds is in the 34th Row and so I select G34, I wan
the scanned card of that card to pop up in cell B2. The card locatio
would be C:\Documents and Settings\ahoekst\My Documents\M
Pictures\1997BarryBonds.jpg

Is this possible, or am I going to have to insert every card into th
excel document and then hide and unhide the card somehow?

Thanks,
TyeJa
 
How about using a hyperlink that pops open whatever JPEG viewer you use
(separate application):

=hyperlink("c\thatlongpath\" & m2 & g2 & ".jpg","click here to view")
and drag down.


I think that if you have lots of cards, you won't want to include all the
pictures in your excel file--it'll become really large.
 
Thanks for your reply Dave, that is actually how I have it right now
but I was just hoping there was a way to have it open up the pictur
within excell instead of like a pop up. I think I may have to jus
keep it the way it is now. Unless someone knows of a different way.

Thanks,
TyeJa
 
Well, I wouldn't do it, but maybe something like this will get you started:

Option Explicit
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)

Dim testStr As String
Dim myFileName As String
Dim myPict As Picture

Set Target = Target(1)

myFileName = "C:\Documents and Settings\ahoekst\My Documents" _
& "\My pictures\" _
& Me.Cells(Target.Row, "M").Value _
& Me.Cells(Target.Row, "G").Value _
& ".jpg"

testStr = ""
On Error Resume Next
testStr = Dir(myFileName)
On Error GoTo 0

If testStr = "" Then
MsgBox "file not found"
Exit Sub
End If

Cancel = True
With Me.Cells(Target.Row, "n")
Set myPict = .Parent.Pictures.Insert(myFileName)
myPict.Top = .Top
myPict.Left = .Left
' myPict.Width = .Width
' myPict.Height = .Height
myPict.Placement = xlMoveAndSize
End With

End Sub

Right click on the worksheet that contains the data and select view code. Paste
this into the code window.

When you rightclick on a cell in that row, it'll try to load the picture into
column N of that row.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
There is an easy way to accomplish this through VBA macros in 3 simpl
Steps:

STEP 1.[/B]WRITE A MACRO THAT RETRIEVES A CARD AND INSERTS IT TO A
LOCATION ON THE SPREADSHEET

TURN ON THE MACRO RECORDER (TOOLS -> MACRO -> RECORD). SELECT CEL
\"B2\". CHOOSE INSERT -> PICTURE FROM THE INSERT MENU. SELECT TH
DIRECTORY HOLDING YOUR CARD IMAGES AND INSERT ONE. TURN OFF THE MACR
RECORDER (TOOLS -> MACRO -> STOP RECORDING).

*STEP 2.* REFINE THE CODE TO ALLOW THE SELECTION OF A SPECIFIC FILE T
DISPLAY:

GO TO THE MACRO MENU AND CHOOSE TO EDIT THE MACRO YOU JUST CREATED.
IT SHOULD LOOK SOMETHING LIKE:

SUB MACRO1()
'
' MACRO1 MACRO
' MACRO RECORDED 9/13/2004 BY CORUNDUM
'
RANGE(\"B2\").SELECT
ACTIVESHEET.PICTURES.INSERT( _
\"C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR\MY DOCUMENTS\M
PICTURES\BALROG.JPG\").SELECT

END SUB

EDIT THE CODE TO LOOK LIKE THIS:

SUB MACRO1()
'
' MACRO1 MACRO
' MACRO RECORDED 9/13/2004 BY CORUNDUM
'
*' THIS ADDITIONAL CODE OPENS AN INPUT BOX WHERE YO
SPECIFY WHICH CARD TO VIEW*
CARDNAME = INPUTBOX(\"ENTER CARD NAME: \")

*' THIS ADDITIONAL CODE INSERTS THE CARD FILE NAME INT
THE COMPLETE PATHNAM
Filename = "C:\Documents and Settings\ahoekst\My Documents\M
Pictures\" + CardName + ".jpg"
Range("B2").Select

' FINALLY, REPLACE THE FIXED PATHNAME OF THE ORIGINA
MACRO WITH THE VARIABLE FILENAM
ActiveSheet.Pictures.Insert(Filename).Select
End Sub

Step 3.* Add a button to your sheet and associate your new Macro t
it

There are more sophisticated solutions but I think this will put you o
the path by seeing how to create a macro VBA code and tailor it to you
purpos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top