Excel VBA...Linking to a vba picture holder

  • Thread starter Thread starter booboo
  • Start date Start date
B

booboo

Help Please!

I've got an excel prog that uses a hyperlink to display a .jpg from
directory. It works fine but opens psp7 every time and then psp asks i
i want to save it again.

I've put a vba image box on the spreadsheet BUT have got totally los
trying to link it to the hyperlink.

a quick bit of info...

Col A , rows 1 to 199 contain links to the folder with images in.

Col B is data to be copied to an xml file which comes from Gmax
(fltsim 2004 stuff).

I've put the vba image box in col D and of course it shows a piccy..
If I alter the properties to the full path.

Is there any way of linking the hyperlink so that instead of startin
psp7 it will put the pic straight into the box ???

Any help or pointers in the right direct appreciated..


Cheers
Booboo (uk
 
I don't don't think a hyperlink will work. But...

So you have one image box in column D--it'll hold whatever picture you want??

Maybe you could use a little macro that works when you rightclick on a single
cell in column A.

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

Dim testStr As String
If Target.Cells.Count > 1 Then Exit Sub

If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub

On Error Resume Next
testStr = Dir(Target.Value)
On Error GoTo 0

If testStr = "" Then
Beep
Else
Me.Image1.Picture = LoadPicture(Filename:=Target.Value)
Cancel = True
End If
End Sub




My image box was named Image1.

Rightclick on the worksheet tab that should have this behavior. Select view
code and paste this into the code window.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

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