B
Bernie Deitrick
John,
As long as you are using pictures from the same folder, you can do something like this: the first
one inserts the file, the second one tells you its name (though it must be selected)
Dim myName As String
Dim myPicName As String
Const myPath As String = "C:\Documents and Settings\DEITBE\My Documents\My Pictures\"
Sub InsertPicture()
myName = "0ead1e14.jpg"
ActiveSheet.Pictures.Insert(myPath & myName).Select
'get rid of spaces and periods, illegal characters in picture names
myPicName = Replace(Replace(myName, ".", "xxx"), " ", "qqq")
MsgBox myPicName
End Sub
Sub WhatFileNameIsPicture()
Selection.Name = myPicName
MsgBox myPath & Replace(Replace(Selection.Name, "qxq", "\"), "xxx", ".")
End Sub
HTH,
Bernie
MS Excel MVP
As long as you are using pictures from the same folder, you can do something like this: the first
one inserts the file, the second one tells you its name (though it must be selected)
Dim myName As String
Dim myPicName As String
Const myPath As String = "C:\Documents and Settings\DEITBE\My Documents\My Pictures\"
Sub InsertPicture()
myName = "0ead1e14.jpg"
ActiveSheet.Pictures.Insert(myPath & myName).Select
'get rid of spaces and periods, illegal characters in picture names
myPicName = Replace(Replace(myName, ".", "xxx"), " ", "qqq")
MsgBox myPicName
End Sub
Sub WhatFileNameIsPicture()
Selection.Name = myPicName
MsgBox myPath & Replace(Replace(Selection.Name, "qxq", "\"), "xxx", ".")
End Sub
HTH,
Bernie
MS Excel MVP