Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How to close an open image...

Hi .. I have the following code ... (thanks to the message board) that
opens an image but I am wondering if it's possible to have the image
automatically close (after maybe a minute)...
I am familiar with "application.wait", but do not know how to close the
file...here's my opening code...any ideas??

Sub OpenButton1_Click()
Dim Picture As String
Dim RETVAL
Picture = "c:\picfolder\" & ActiveSheet.Range("C2").Value & ".tif"
RETVAL = Shell("EXPLORER " & Picture, 1)
End Sub

Any help would be greatly appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default How to close an open image...

Is is possible, if somewhat messy to achieve.

Determine the application that opens the picture; it could be Paint or
another application with which the extension TIF is associated.

Use the FindWindow API call to get the handle of the Window for that
application. If you do not know the class name, use the caption (the latter
is less reliable as it is difficult to get right ... it has to match exactly).

Use the PostMessage API to send a WM_CLOSE message to the Window handle.

The APIs a

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long

Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd
As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As
Long

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How to close an open image...

Well does anyone know of a picture viewer (or have any ideas) that
prohibits the user from doing anything except closing it. I figured I
could disable a the escape key and user a fullscreen view if I could
automatically close the file. My problem is all the viewers have print
and edit functions and I do not want the viewer to have those
options???
Anyone with any suggestions on how I can overcome that?
Regards

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default How to close an open image...

Could you draw from a set of pictures that were gif files rather than tif.
Then you could create a UserForm, fill it with an image control and use
something like

Fname = "C:\pictureSet\myPic.gif"
Image1.Picture = LoadPicture(Fname)

inside a UserForm Activate sub.

It is easy to set a timer for a userform and the only thing the user would
be able to do would be to shut the form down before your timer did it
automatically.

I did a quick test with a tif file and, unfortunately, that won't work.

Steve


"obsessive" wrote in message
oups.com...
Well does anyone know of a picture viewer (or have any ideas) that
prohibits the user from doing anything except closing it. I figured I
could disable a the escape key and user a fullscreen view if I could
automatically close the file. My problem is all the viewers have print
and edit functions and I do not want the viewer to have those
options???
Anyone with any suggestions on how I can overcome that?
Regards



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How to close an open image...

Thanks for the reply... that may be my only option... I would have to
convert all the files but if thats what I have to do... so be it I
guess.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default How to close an open image...

My original thought was to create an IE window that could easily be
controlled but many users will have registry settings that will result in a
TIF image appearing as an image placeholder in the IE window.

Can you be certain that your users will all be using WinME, WinXP, Win2k or
beyond? If that is the case, you could use the Windows picture and fax
viewer to show the picture and use WMI to isolate the process and terminate
it on your schedule. That won't work if any users are using Win98 or
earlier.

Steve



"obsessive" wrote in message
ups.com...
Thanks for the reply... that may be my only option... I would have to
convert all the files but if thats what I have to do... so be it I
guess.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How to close an open image...

Well I'm certain of the users will be using winXP but I have no idea
how to use WMI to isolate and terminate the process??
Can you give me more info ?

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default How to close an open image...

WMI will let you obtain a collection of all the running processes. One of
the properties of each process is commandline and one of the methods is
terminate. Since you can be fairly sure that the process displaying your
tif file will be the only process containing the name of the file as part of
its command line, you could use something like the following to terminate
that process.

_ _ _ _ _ _ _ _ _ _

strPicture = "c:\picfolder\" & ActiveSheet.Range("C2").Value & ".tif"

Set objWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\.\root\cim v2")
Set colProcess = objWMI.ExecQuery _
("Select * from Win32_Process")

For Each objProcess In colProcess
If InStr(objProcess.CommandLine, strPicture) 0 Then
objProcess.Terminate
End If
Next
_ _ _ _ _ _ _ _ _ _


Steve



"obsessive" wrote in message
oups.com...
Well I'm certain of the users will be using winXP but I have no idea
how to use WMI to isolate and terminate the process??
Can you give me more info ?



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How to close an open image...

Hey Steve,
Thanks for all your help. After much time and thought I have opted to
change all my image files to bitmaps and go with a userform.
I figure I'll just maximize the userform and add a couple of zoom and
scroll functions. That should suffice. Thanks again for your time
and your help. I appreciate it.

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
open image file from cell value el_peacock Excel Programming 7 May 2nd 06 05:34 PM
if its open...close it choice[_2_] Excel Programming 10 August 16th 04 01:19 PM
Open then Close Markus Excel Programming 2 July 14th 04 07:44 PM
Open image from web in window same size as image? Milos Setek Excel Programming 0 February 5th 04 03:33 AM


All times are GMT +1. The time now is 08:32 PM.

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

About Us

"It's about Microsoft Excel"