ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to view graphic files from excel? (https://www.excelbanter.com/excel-programming/286793-how-view-graphic-files-excel.html)

Kiknadze Lado

How to view graphic files from excel?
 
Dear all,

Let I have excel sheet with two columns:

RefNo, Description

g1234 file1
g1235 file2
g1236 file3
................

First column cell values connected with graphic file names from the same
directory. This means that I have graphic files: g1234.jpg, g1235.jpg,
g1236.jpg ....in the same directory there is opened worksheet.
I want to write program which will operate by following way:
If I will click cell with the value g1234 then I want to view graphic file
g1234.jpg. This means that will be appeared window (maybe Internet Explorer
window or other) there I will see graphic file g1234.jpg.

I will appreciate any your help.
Lado



Chip Pearson

How to view graphic files from excel?
 
Lado,

Try the following code in the code module for the appropriate
worksheet:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim WS As Worksheet
Set WS = ActiveSheet
WS.OLEObjects("Image1").Object.Picture = _
LoadPicture(ThisWorkbook.Path & "\" & Target.Text &
".jpg")

End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Kiknadze Lado" wrote in message
...
Dear all,

Let I have excel sheet with two columns:

RefNo, Description

g1234 file1
g1235 file2
g1236 file3
...............

First column cell values connected with graphic file names from

the same
directory. This means that I have graphic files: g1234.jpg,

g1235.jpg,
g1236.jpg ....in the same directory there is opened worksheet.
I want to write program which will operate by following way:
If I will click cell with the value g1234 then I want to view

graphic file
g1234.jpg. This means that will be appeared window (maybe

Internet Explorer
window or other) there I will see graphic file g1234.jpg.

I will appreciate any your help.
Lado





Chip Pearson

How to view graphic files from excel?
 
Or, more robust,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim WS As Worksheet
Dim FName As String
If Not Application.Intersect(Range("A1:A10"), Target) _
Is Nothing Then
FName = ThisWorkbook.Path & "\" & Target.Text & ".jpg"
If Dir(FName) < "" Then
Set WS = ActiveSheet
WS.OLEObjects("Image1").Object.Picture = _
LoadPicture(FName)
End If
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Chip Pearson" wrote in message
...
Lado,

Try the following code in the code module for the appropriate
worksheet:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim WS As Worksheet
Set WS = ActiveSheet
WS.OLEObjects("Image1").Object.Picture = _
LoadPicture(ThisWorkbook.Path & "\" & Target.Text &
".jpg")

End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Kiknadze Lado" wrote in message
...
Dear all,

Let I have excel sheet with two columns:

RefNo, Description

g1234 file1
g1235 file2
g1236 file3
...............

First column cell values connected with graphic file names

from
the same
directory. This means that I have graphic files: g1234.jpg,

g1235.jpg,
g1236.jpg ....in the same directory there is opened

worksheet.
I want to write program which will operate by following way:
If I will click cell with the value g1234 then I want to view

graphic file
g1234.jpg. This means that will be appeared window (maybe

Internet Explorer
window or other) there I will see graphic file g1234.jpg.

I will appreciate any your help.
Lado







Tom Ogilvy

How to view graphic files from excel?
 
Make the refno a hyperlink.

Insert=Hyperlink.

--
Regards,
Tom Ogilvy

Kiknadze Lado wrote in message
...
Dear all,

Let I have excel sheet with two columns:

RefNo, Description

g1234 file1
g1235 file2
g1236 file3
...............

First column cell values connected with graphic file names from the same
directory. This means that I have graphic files: g1234.jpg, g1235.jpg,
g1236.jpg ....in the same directory there is opened worksheet.
I want to write program which will operate by following way:
If I will click cell with the value g1234 then I want to view graphic file
g1234.jpg. This means that will be appeared window (maybe Internet

Explorer
window or other) there I will see graphic file g1234.jpg.

I will appreciate any your help.
Lado





Kiknadze Lado

How to view graphic files from excel?
 
Thank you all. This helped me.
Best,
Lado

"Tom Ogilvy" wrote in message
...
Make the refno a hyperlink.

Insert=Hyperlink.

--
Regards,
Tom Ogilvy

Kiknadze Lado wrote in message
...
Dear all,

Let I have excel sheet with two columns:

RefNo, Description

g1234 file1
g1235 file2
g1236 file3
...............

First column cell values connected with graphic file names from the same
directory. This means that I have graphic files: g1234.jpg, g1235.jpg,
g1236.jpg ....in the same directory there is opened worksheet.
I want to write program which will operate by following way:
If I will click cell with the value g1234 then I want to view graphic

file
g1234.jpg. This means that will be appeared window (maybe Internet

Explorer
window or other) there I will see graphic file g1234.jpg.

I will appreciate any your help.
Lado








All times are GMT +1. The time now is 06:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com