View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Create N variables

OK if it's to keep a record of picture properties "were" indeed you are
going the right way and use Dave's examples. I had wrongly speculated the
intension was to use the properties immediately.

Only for "amusement", as you had put it that way, here's another approach
(not better just different)

Private Type tPicProps
Name As String
Left As Double
Top As Double
rTLcell As Range
End Type

Private arrPicProps() As tPicProps ' at module level for later recall

Sub LetPicProps()
Dim i As Long, cntPics As Long
Dim pic As Picture

cntPics = ActiveSheet.Pictures.Count
If cntPics = 0 Then
Exit Sub
End If

ReDim arrPicProps(1 To cntPics)
For i = 1 To cntPics
Set pic = ActiveSheet.Pictures(i)
With arrPicProps(i)
Set .rTLcell = pic.TopLeftCell
.Left = pic.Left
.Top = pic.Top
.Name = pic.Name
End With
Next
End Sub

Sub GetOldPicProps()

For i = 1 To UBound(arrPicProps)
With arrPicProps(i)
Debug.Print .Name, .rTLcell.Address, .Left, .Top
End With
Next

End Sub

Sub ErasePicProps() ' call this when done
Erase arrPicProps
End Sub

' note the rTLcell range-object is not really a "record", it could have been
be cut and moved in the interim. Just to illustrate how you can use a "Type"

Regards,
Peter T


"Jive" wrote in message
...
Yes that is the objective. I'm looking to construct a record of what
pictures have been moved and where.

I was planning to look for changes in the vlaues and then list out the
sequence of moves.

Are you asking as you can suggest a better approach?

"Peter T" wrote:

Why do that! You've always got the latest up to date properties of all
pictures in the collection "mySheet.Pictures". The only reason to assign
their properties elsewhere would be to keep a record of what they were
before changing them - is that the objective?

Regards,
Peter T




"Jive" wrote in message
...
I have a piece of vba code which can be simplified to

Dim Piece As Picture
For Each Piece In ActiveSheet.Pictures
******
******
******
Next Piece

Within the piece iteration I wish to retrieve some information about
each
picture and store it as a variable i.e. variable(1.....n) =
Piece(1.....n).topleftcell. I am unsure how to automatically generate
variable sequence to the correct number of variables. i.e. so that it
stores
a new variable and value for later use off of each loop.

VBA is amusing, there is always something new to learn and when you do
you
only have another two things to learn afther that so please help.
thanks
in
advance.