Reassign Picture name (Texas Hold'em)

  • Thread starter Thread starter MJSlattery
  • Start date Start date
M

MJSlattery

There seems to be an automatic naming process as you insert or paste
picture into a worksheet.

Is there a way to changing that name so that it can be selected in
VBA macro?

If that is not possiable how do I get the auto assigned name of
pasted picture so that I can refer to that in my macro.

Working on a Texas Hold'em Calculator

Willing to share if your willing to contribute.

Michae
 
You can set the name when you add it to the sheet:

(Save from a previous post.)

Option Explicit
Sub testme()

Dim myRng As Range
Dim myCell As Range
Dim wks As Worksheet
Dim myPict As Picture
Dim myPictName As String

myPictName = "C:\My Documents\My Pictures\clouds.jpg"

Set wks = ActiveSheet
With wks
.Pictures.Delete 'remove existing pictures???
Set myRng = .Range("a1:a10")
For Each myCell In myRng.Cells
With myCell
Set myPict = .Parent.Pictures.Insert(myPictName)
myPict.Height = .Height
myPict.Width = .Width
myPict.Left = .Left
myPict.Top = .Top
myPict.Name = "Pict_" & .Address(0, 0)
myPict.OnAction = ThisWorkbook.Name & "!myPictmacro"
End With
Next myCell
End With
End Sub
Sub myPictMacro()
Dim myPict As Picture

Set myPict = ActiveSheet.Pictures(Application.Caller)
With myPict
MsgBox .TopLeftCell.Address(0, 0) & vbLf & .Name
End With

End Sub

(along with other things--including a macro that will run when you click the
picture.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top