ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to know the picture is open (https://www.excelbanter.com/excel-programming/320952-how-know-picture-open.html)

Dorothy Lo

how to know the picture is open
 
I am using MS Office 2003 and writing VBA in Excel.

I have a picture which is not inserted in Excel and saves in a folder. I
want to know if the picture is opening or not. Because I have to make sure
the picture is not opening before renaming it.

Do you have any solution to know if the picture is opening?
Appreciate for your kind post.

Dave Peterson[_5_]

how to know the picture is open
 
Microsoft has an IsFileOpen function at:
http://support.microsoft.com?kbid=138621

But when I opened some .jpg's in various programs (irfanview, paint, imaging),
the file showed not in use. I could even delete it.

Could you try to just rename it and then check to see if it was successful:

Option Explicit
Sub testme()

Dim MyOldFileName As String
Dim myNewFileName As String

MyOldFileName = "c:\my documents\my pictures\keyboard2.jpg"
myNewFileName = "c:\my documents\my pictures\keyboard.jpg"

If Dir(MyOldFileName) = "" Then
MsgBox "It's not there!"
Else
On Error Resume Next
Name MyOldFileName As myNewFileName
If Err.Number < 0 Then
MsgBox "Rename failed, it may be in use elsewhere"
Err.Clear
End If
End If

End Sub

Dorothy Lo wrote:

I am using MS Office 2003 and writing VBA in Excel.

I have a picture which is not inserted in Excel and saves in a folder. I
want to know if the picture is opening or not. Because I have to make sure
the picture is not opening before renaming it.

Do you have any solution to know if the picture is opening?
Appreciate for your kind post.


--

Dave Peterson


All times are GMT +1. The time now is 05:42 PM.

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