Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Displaying jpegs.

I am running Office 2000 in WinXP.

I have a need to display several dozen .jpg files, each 10 megs or so in
size in a workbook, with 4 or 5 of them accessable from each worksheet.
Placing each entire picture into the workbook, it becomes unwieldy in size.
I have decided to place buttons on each worsheet with thumbnails of the
picture to be displayed on the button, so that when the button is pressed,
the full size file is displayed.

The following VBA code works:

Dim RetVal
RetVal = Shell("rundll32.exe
C:\WINDOWS\system32\shimgvw.dll,ImageView_Fullscre en
picture_name_and_path.jpg", 1)

This displays the full size picture in Windows picture and fax viewer. It is
a solution I can live with. But what I really want to do is to display the
picture using whatever the default .jpg viewer is for that computer just as
if the picture file was double clicked.

There must be some function such as "show using default pic.jpg"

If this is not clear, I can further explain.

Thanks




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Displaying jpegs.

You have a few choices.
..FollowHyperlink will open it in IE.
The ShellExecute API will open in the app associated with that file type.

Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String,
ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1

Private Sub CommandButton3_Click()
Dim RetVal As Long

Const FileName As String = "C:\Sample.jpg"

ThisWorkbook.FollowHyperlink FileName
'or
RetVal = ShellExecute(Application.hwnd, "open", FileName, vbNullString,
"C:\", SW_SHOWNORMAL)

End Sub

Or you could keep it all inside Excel, by using an Image control (on the WS
or modeless userform) and load the picture into that.
That way it is not saved with the WB.

NickHK

"videor" wrote in message
. ..
I am running Office 2000 in WinXP.

I have a need to display several dozen .jpg files, each 10 megs or so in
size in a workbook, with 4 or 5 of them accessable from each worksheet.
Placing each entire picture into the workbook, it becomes unwieldy in

size.
I have decided to place buttons on each worsheet with thumbnails of the
picture to be displayed on the button, so that when the button is pressed,
the full size file is displayed.

The following VBA code works:

Dim RetVal
RetVal = Shell("rundll32.exe
C:\WINDOWS\system32\shimgvw.dll,ImageView_Fullscre en
picture_name_and_path.jpg", 1)

This displays the full size picture in Windows picture and fax viewer. It

is
a solution I can live with. But what I really want to do is to display the
picture using whatever the default .jpg viewer is for that computer just

as
if the picture file was double clicked.

There must be some function such as "show using default pic.jpg"

If this is not clear, I can further explain.

Thanks






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Displaying jpegs.

Thanks for the additional ideas. I got the IE version to work, and the Image
control. However, I can't get the ShellExecute to work. The statement
"retval=shellexecute(..." crashes with a "object doesn't support this
property or method" message. the entire statement is highlighted.

bern muller


"NickHK" wrote in message
...
You have a few choices.
.FollowHyperlink will open it in IE.
The ShellExecute API will open in the app associated with that file type.

Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As
String,
ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1

Private Sub CommandButton3_Click()
Dim RetVal As Long

Const FileName As String = "C:\Sample.jpg"

ThisWorkbook.FollowHyperlink FileName
'or
RetVal = ShellExecute(Application.hwnd, "open", FileName, vbNullString,
"C:\", SW_SHOWNORMAL)

End Sub

Or you could keep it all inside Excel, by using an Image control (on the
WS
or modeless userform) and load the picture into that.
That way it is not saved with the WB.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Displaying jpegs.


This is part of the Windows API. Excel/VBA know nothing about it, so you
have include the declarations that I included, in the top section of the
code module:

Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String,
ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1

NickHK


"videor" wrote in message
. ..
Thanks for the additional ideas. I got the IE version to work, and the

Image
control. However, I can't get the ShellExecute to work. The statement
"retval=shellexecute(..." crashes with a "object doesn't support this
property or method" message. the entire statement is highlighted.

bern muller


"NickHK" wrote in message
...
You have a few choices.
.FollowHyperlink will open it in IE.
The ShellExecute API will open in the app associated with that file

type.

Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As
String,
ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1

Private Sub CommandButton3_Click()
Dim RetVal As Long

Const FileName As String = "C:\Sample.jpg"

ThisWorkbook.FollowHyperlink FileName
'or
RetVal = ShellExecute(Application.hwnd, "open", FileName, vbNullString,
"C:\", SW_SHOWNORMAL)

End Sub

Or you could keep it all inside Excel, by using an Image control (on the
WS
or modeless userform) and load the picture into that.
That way it is not saved with the WB.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Displaying jpegs.

I had done that. But based on your assurance that was what should be done, I
did a little troubleshooting and found the problem:

The call as you sent it was: (without quotes)

"RetVal = ShellExecute(Application.hwnd, "open", FileName, vbNullString,
"C:\", SW_SHOWNORMAL)"

I changed it to:

"RetVal = ShellExecute(hwnd, "open", FileName, vbNullString,
"C:\", SW_SHOWNORMAL)"

and that seems to work. Any reason not to do it that way?

Thanks for all the help.

bern

"NickHK" wrote in message
...

This is part of the Windows API. Excel/VBA know nothing about it, so you
have include the declarations that I included, in the top section of the
code module:

Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As
String,
ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1

NickHK





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Displaying jpegs.

What is your value of hwnd ?

This should be the Windows handle of the parents window, hence
Application.hwnd.
This only works in Excel 2002 and higher.
In earlier versions, you should use the FindWindow API.

NickHK

"videor" wrote in message
. ..
I had done that. But based on your assurance that was what should be done,

I
did a little troubleshooting and found the problem:

The call as you sent it was: (without quotes)

"RetVal = ShellExecute(Application.hwnd, "open", FileName, vbNullString,
"C:\", SW_SHOWNORMAL)"

I changed it to:

"RetVal = ShellExecute(hwnd, "open", FileName, vbNullString,
"C:\", SW_SHOWNORMAL)"

and that seems to work. Any reason not to do it that way?

Thanks for all the help.

bern

"NickHK" wrote in message
...

This is part of the Windows API. Excel/VBA know nothing about it, so you
have include the declarations that I included, in the top section of the
code module:

Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As
String,
ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1

NickHK





Reply
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
Hiding Jpegs in excel Nelson B. Excel Discussion (Misc queries) 2 February 13th 09 01:46 PM
Is there a way to hide JPegs in excel? Nelson B. Excel Discussion (Misc queries) 1 February 10th 09 06:14 PM
Inporting JPEGs Pete Charts and Charting in Excel 1 January 13th 08 03:35 PM
jpegs in cells David Excel Discussion (Misc queries) 5 October 27th 06 11:51 PM
transferring jpegs dick Excel Discussion (Misc queries) 0 October 12th 06 10:39 AM


All times are GMT +1. The time now is 10:06 PM.

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"