Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Move shape, object, pic to center of new cell based on cell value
Hi,
I will be amazed if anyone could break this code!! This is actually a kind of animation. I want to be able to put any object, shape or picture over a cell and positively know the over-the-cell-reference. Then in a table (cell) on the same cell I want to be able to enter the following parameters: 1. Move object to cell [reference], 2. Moving speed / time, 3. Delay before moving. By running several of these events I should be able to make a triangel move from cell A1 to B1 to C1 to C2 to A7, etc. Next job will be to allow several objects to move simultaneously in different paths. Does anyone have a solution to this? -- Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Move shape, object, pic to center of new cell based on cell value
Sounds like you'll need a collection of instances of an object with
properties of Object, celllist(), active, speed, delay, etc. Then loop through the collection calling the MoveMe method on each instance, if it is active. NickHK "zzxxcc" wrote in message ... Hi, I will be amazed if anyone could break this code!! This is actually a kind of animation. I want to be able to put any object, shape or picture over a cell and positively know the over-the-cell-reference. Then in a table (cell) on the same cell I want to be able to enter the following parameters: 1. Move object to cell [reference], 2. Moving speed / time, 3. Delay before moving. By running several of these events I should be able to make a triangel move from cell A1 to B1 to C1 to C2 to A7, etc. Next job will be to allow several objects to move simultaneously in different paths. Does anyone have a solution to this? -- Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Move shape, object, pic to center of new cell based on cell va
NickHK,
You may be right. What I need is some guidance to how to make the code. If it is easier you (or anyone) could list each code separately. Personally I am only at the level of copying codes into VB. Just beeing able to move from cell A1 to cell A2 would be a great help as a starter. -- Thanks "NickHK" wrote: Sounds like you'll need a collection of instances of an object with properties of Object, celllist(), active, speed, delay, etc. Then loop through the collection calling the MoveMe method on each instance, if it is active. NickHK "zzxxcc" wrote in message ... Hi, I will be amazed if anyone could break this code!! This is actually a kind of animation. I want to be able to put any object, shape or picture over a cell and positively know the over-the-cell-reference. Then in a table (cell) on the same cell I want to be able to enter the following parameters: 1. Move object to cell [reference], 2. Moving speed / time, 3. Delay before moving. By running several of these events I should be able to make a triangel move from cell A1 to B1 to C1 to C2 to A7, etc. Next job will be to allow several objects to move simultaneously in different paths. Does anyone have a solution to this? -- Thanks |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Move shape, object, pic to center of new cell based on cell va
<Class cAniPic
'Private variables Private mPic As Shape Private mCellList As Range Private mDelay As Long Private mCurrentPos As Long Private WithEvents mTimer As CTimer Public Property Set ThisPic(vData As Shape) Set mPic = vData End Property Public Property Set CellList(vData As Range) Set mCellList = vData 'Debug.Print mCellList.Address End Property Public Property Let Delay(vData As Long) mDelay = vData mTimer.Interval = vData End Property Public Function ReSet() mCurrentPos = 1 Call MovePic End Function Public Function Animate(StopAnimate As Boolean) mTimer.Enabled = Not StopAnimate End Function 'Private functions Private Sub Class_Initialize() Set mTimer = New CTimer End Sub Private Sub Class_Terminate() Set mPic = Nothing Set mCellList = Nothing Set mTimer = Nothing End Sub 'Helper functions Private Function MovePic() With mCellList.Areas(mCurrentPos) mPic.Top = .Top mPic.Left = .Left mPic.Height = .Height mPic.Width = .Width End With End Function Private Sub mTimer_Timer() If mCurrentPos = mCellList.Areas.Count Then mCurrentPos = 1 Else mCurrentPos = mCurrentPos + 1 End If Call MovePic End Sub <Class cAniPic You will also need the class based timer from Karl: http://vb.mvps.org/samples/project.asp?id=TimerObj Then on a worksheet, add a couple of command buttons and insert a pictu <Worksheet code Dim MovePic As cAniPic Private Sub cmdStart_Click() Set MovePic = New cAniPic With MovePic Set .ThisPic = ActiveSheet.Shapes("Picture 1") 'Or whatever the picture is called 'Change the ranges to those you want Set .CellList = Union(Range("A1"), Range("C15:D18"), Range("A4"), Range("C1"), Range("F6")) .Delay = 500 'Milliseconds .ReSet .Animate False End With End Sub Private Sub cmdStop_Click() With MovePic .Animate True End With Set MovePic = Nothing End Sub Once you understand this, you can create a collection of these to handle multiple instances. No error handling or much testing, but you can do that. You can still use the sheet as normal, but animation will pause whilst you are in edit mode i.e. entering text in cells. NickHK "zzxxcc" wrote in message ... NickHK, You may be right. What I need is some guidance to how to make the code. If it is easier you (or anyone) could list each code separately. Personally I am only at the level of copying codes into VB. Just beeing able to move from cell A1 to cell A2 would be a great help as a starter. -- Thanks "NickHK" wrote: Sounds like you'll need a collection of instances of an object with properties of Object, celllist(), active, speed, delay, etc. Then loop through the collection calling the MoveMe method on each instance, if it is active. NickHK "zzxxcc" wrote in message ... Hi, I will be amazed if anyone could break this code!! This is actually a kind of animation. I want to be able to put any object, shape or picture over a cell and positively know the over-the-cell-reference. Then in a table (cell) on the same cell I want to be able to enter the following parameters: 1. Move object to cell [reference], 2. Moving speed / time, 3. Delay before moving. By running several of these events I should be able to make a triangel move from cell A1 to B1 to C1 to C2 to A7, etc. Next job will be to allow several objects to move simultaneously in different paths. Does anyone have a solution to this? -- Thanks |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Move shape, object, pic to center of new cell based on cell va
I am Amazed! Thanks a lot NickHK. I will try to understand this and then
modify as described. Great! -- Thanks "NickHK" wrote: <Class cAniPic 'Private variables Private mPic As Shape Private mCellList As Range Private mDelay As Long Private mCurrentPos As Long Private WithEvents mTimer As CTimer Public Property Set ThisPic(vData As Shape) Set mPic = vData End Property Public Property Set CellList(vData As Range) Set mCellList = vData 'Debug.Print mCellList.Address End Property Public Property Let Delay(vData As Long) mDelay = vData mTimer.Interval = vData End Property Public Function ReSet() mCurrentPos = 1 Call MovePic End Function Public Function Animate(StopAnimate As Boolean) mTimer.Enabled = Not StopAnimate End Function 'Private functions Private Sub Class_Initialize() Set mTimer = New CTimer End Sub Private Sub Class_Terminate() Set mPic = Nothing Set mCellList = Nothing Set mTimer = Nothing End Sub 'Helper functions Private Function MovePic() With mCellList.Areas(mCurrentPos) mPic.Top = .Top mPic.Left = .Left mPic.Height = .Height mPic.Width = .Width End With End Function Private Sub mTimer_Timer() If mCurrentPos = mCellList.Areas.Count Then mCurrentPos = 1 Else mCurrentPos = mCurrentPos + 1 End If Call MovePic End Sub <Class cAniPic You will also need the class based timer from Karl: http://vb.mvps.org/samples/project.asp?id=TimerObj Then on a worksheet, add a couple of command buttons and insert a pictu <Worksheet code Dim MovePic As cAniPic Private Sub cmdStart_Click() Set MovePic = New cAniPic With MovePic Set .ThisPic = ActiveSheet.Shapes("Picture 1") 'Or whatever the picture is called 'Change the ranges to those you want Set .CellList = Union(Range("A1"), Range("C15:D18"), Range("A4"), Range("C1"), Range("F6")) .Delay = 500 'Milliseconds .ReSet .Animate False End With End Sub Private Sub cmdStop_Click() With MovePic .Animate True End With Set MovePic = Nothing End Sub Once you understand this, you can create a collection of these to handle multiple instances. No error handling or much testing, but you can do that. You can still use the sheet as normal, but animation will pause whilst you are in edit mode i.e. entering text in cells. NickHK "zzxxcc" wrote in message ... NickHK, You may be right. What I need is some guidance to how to make the code. If it is easier you (or anyone) could list each code separately. Personally I am only at the level of copying codes into VB. Just beeing able to move from cell A1 to cell A2 would be a great help as a starter. -- Thanks "NickHK" wrote: Sounds like you'll need a collection of instances of an object with properties of Object, celllist(), active, speed, delay, etc. Then loop through the collection calling the MoveMe method on each instance, if it is active. NickHK "zzxxcc" wrote in message ... Hi, I will be amazed if anyone could break this code!! This is actually a kind of animation. I want to be able to put any object, shape or picture over a cell and positively know the over-the-cell-reference. Then in a table (cell) on the same cell I want to be able to enter the following parameters: 1. Move object to cell [reference], 2. Moving speed / time, 3. Delay before moving. By running several of these events I should be able to make a triangel move from cell A1 to B1 to C1 to C2 to A7, etc. Next job will be to allow several objects to move simultaneously in different paths. Does anyone have a solution to this? -- Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Move object with cell | Setting up and Configuration of Excel | |||
how do I move a cell based on a match of another cell in excel? | Excel Worksheet Functions | |||
draw shape based on cell values | Excel Programming | |||
how do I use a macro to center a shape in a cell in excel | Excel Programming |