#1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default animation

I have an animated excel file with a picture rolling from left to right of
the screen. The is done when I click on the picture. My first problem is that
the picture rolls very fast and I want to reduce its speed, and the second
problem is that I want this animation not when I click on the picture but
when I open the file. I am using Excel 2007 and below is the code that I am
using. Any help.

Thanks.

Code:

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default animation

1. For making it slow use a timer in betwen the For loop. Adjust the seconds
as needed
Application.Wait Now + TimeValue("00:00:05")

2. If you want this to happen during open write the code in Workbook_Open()
event

If this post helps click Yes
---------------
Jacob Skaria


"MAX" wrote:

I have an animated excel file with a picture rolling from left to right of
the screen. The is done when I click on the picture. My first problem is that
the picture rolls very fast and I want to reduce its speed, and the second
problem is that I want this animation not when I click on the picture but
when I open the file. I am using Excel 2007 and below is the code that I am
using. Any help.

Thanks.

Code:

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default animation

Max,

application.wait is a bit of a blunt instrument so try this instead

Alt+F11 to open VB editor, right click 'ThisWorkbook' and insert module and
paste the code below in. In each of the 2 loops in your code add the line

wait(0.08)

the 0.08 gave me a nice smooth scroll but you can play with this.

Sub Wait(DelaySecs As Single)
Dim sngSec As Single
EndDelay = Timer + DelaySecs
Do While Timer < EndDelay
DoEvents
Loop
End Sub

Mike

"MAX" wrote:

I have an animated excel file with a picture rolling from left to right of
the screen. The is done when I click on the picture. My first problem is that
the picture rolls very fast and I want to reduce its speed, and the second
problem is that I want this animation not when I click on the picture but
when I open the file. I am using Excel 2007 and below is the code that I am
using. Any help.

Thanks.

Code:

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default animation

Will you please tell me where I am going to put wait(0.08) because I'm a
beginer in VB.

"Mike H" wrote:

Max,

application.wait is a bit of a blunt instrument so try this instead

Alt+F11 to open VB editor, right click 'ThisWorkbook' and insert module and
paste the code below in. In each of the 2 loops in your code add the line

wait(0.08)

the 0.08 gave me a nice smooth scroll but you can play with this.

Sub Wait(DelaySecs As Single)
Dim sngSec As Single
EndDelay = Timer + DelaySecs
Do While Timer < EndDelay
DoEvents
Loop
End Sub

Mike

"MAX" wrote:

I have an animated excel file with a picture rolling from left to right of
the screen. The is done when I click on the picture. My first problem is that
the picture rolls very fast and I want to reduce its speed, and the second
problem is that I want this animation not when I click on the picture but
when I open the file. I am using Excel 2007 and below is the code that I am
using. Any help.

Thanks.

Code:

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default animation

Max,

Modify your code like this and note the 2 added lines

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Wait (0.08)
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Wait (0.08)
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

Mike

"MAX" wrote:

Will you please tell me where I am going to put wait(0.08) because I'm a
beginer in VB.

"Mike H" wrote:

Max,

application.wait is a bit of a blunt instrument so try this instead

Alt+F11 to open VB editor, right click 'ThisWorkbook' and insert module and
paste the code below in. In each of the 2 loops in your code add the line

wait(0.08)

the 0.08 gave me a nice smooth scroll but you can play with this.

Sub Wait(DelaySecs As Single)
Dim sngSec As Single
EndDelay = Timer + DelaySecs
Do While Timer < EndDelay
DoEvents
Loop
End Sub

Mike

"MAX" wrote:

I have an animated excel file with a picture rolling from left to right of
the screen. The is done when I click on the picture. My first problem is that
the picture rolls very fast and I want to reduce its speed, and the second
problem is that I want this animation not when I click on the picture but
when I open the file. I am using Excel 2007 and below is the code that I am
using. Any help.

Thanks.

Code:

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default animation

Thanks a lot

"Mike H" wrote:

Max,

Modify your code like this and note the 2 added lines

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Wait (0.08)
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Wait (0.08)
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

Mike

"MAX" wrote:

Will you please tell me where I am going to put wait(0.08) because I'm a
beginer in VB.

"Mike H" wrote:

Max,

application.wait is a bit of a blunt instrument so try this instead

Alt+F11 to open VB editor, right click 'ThisWorkbook' and insert module and
paste the code below in. In each of the 2 loops in your code add the line

wait(0.08)

the 0.08 gave me a nice smooth scroll but you can play with this.

Sub Wait(DelaySecs As Single)
Dim sngSec As Single
EndDelay = Timer + DelaySecs
Do While Timer < EndDelay
DoEvents
Loop
End Sub

Mike

"MAX" wrote:

I have an animated excel file with a picture rolling from left to right of
the screen. The is done when I click on the picture. My first problem is that
the picture rolls very fast and I want to reduce its speed, and the second
problem is that I want this animation not when I click on the picture but
when I open the file. I am using Excel 2007 and below is the code that I am
using. Any help.

Thanks.

Code:

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default animation

Very nice timing, but although I put the the code in the workbook I have
still to click on the picture for the animation, I want this when I open the
file.

Thanks for your great help.

"Mike H" wrote:

Max,

Modify your code like this and note the 2 added lines

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Wait (0.08)
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Wait (0.08)
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

Mike

"MAX" wrote:

Will you please tell me where I am going to put wait(0.08) because I'm a
beginer in VB.

"Mike H" wrote:

Max,

application.wait is a bit of a blunt instrument so try this instead

Alt+F11 to open VB editor, right click 'ThisWorkbook' and insert module and
paste the code below in. In each of the 2 loops in your code add the line

wait(0.08)

the 0.08 gave me a nice smooth scroll but you can play with this.

Sub Wait(DelaySecs As Single)
Dim sngSec As Single
EndDelay = Timer + DelaySecs
Do While Timer < EndDelay
DoEvents
Loop
End Sub

Mike

"MAX" wrote:

I have an animated excel file with a picture rolling from left to right of
the screen. The is done when I click on the picture. My first problem is that
the picture rolls very fast and I want to reduce its speed, and the second
problem is that I want this animation not when I click on the picture but
when I open the file. I am using Excel 2007 and below is the code that I am
using. Any help.

Thanks.

Code:

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default animation

To start your demo automatically, put the following event macro in the
workboook code area:

Private Sub Workbook_Open()
Sheets("Sheet1").Activate
Call StartDemo1
End Sub

Adjust the name of the worksheet to match your sheet name.


Because it is workbook code, it is very easy to install and use:

1. right-click the tiny Excel icon just to the left of File on the Menu Bar
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about Event Macros (workbook code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200841


"MAX" wrote:

Very nice timing, but although I put the the code in the workbook I have
still to click on the picture for the animation, I want this when I open the
file.

Thanks for your great help.

"Mike H" wrote:

Max,

Modify your code like this and note the 2 added lines

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Wait (0.08)
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Wait (0.08)
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

Mike

"MAX" wrote:

Will you please tell me where I am going to put wait(0.08) because I'm a
beginer in VB.

"Mike H" wrote:

Max,

application.wait is a bit of a blunt instrument so try this instead

Alt+F11 to open VB editor, right click 'ThisWorkbook' and insert module and
paste the code below in. In each of the 2 loops in your code add the line

wait(0.08)

the 0.08 gave me a nice smooth scroll but you can play with this.

Sub Wait(DelaySecs As Single)
Dim sngSec As Single
EndDelay = Timer + DelaySecs
Do While Timer < EndDelay
DoEvents
Loop
End Sub

Mike

"MAX" wrote:

I have an animated excel file with a picture rolling from left to right of
the screen. The is done when I click on the picture. My first problem is that
the picture rolls very fast and I want to reduce its speed, and the second
problem is that I want this animation not when I click on the picture but
when I open the file. I am using Excel 2007 and below is the code that I am
using. Any help.

Thanks.

Code:

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default animation

As mentioned in my earlier post write the code in Workbook_Open()
event

If this post helps click Yes
---------------
Jacob Skaria


"MAX" wrote:

Very nice timing, but although I put the the code in the workbook I have
still to click on the picture for the animation, I want this when I open the
file.

Thanks for your great help.

"Mike H" wrote:

Max,

Modify your code like this and note the 2 added lines

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Wait (0.08)
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Wait (0.08)
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

Mike

"MAX" wrote:

Will you please tell me where I am going to put wait(0.08) because I'm a
beginer in VB.

"Mike H" wrote:

Max,

application.wait is a bit of a blunt instrument so try this instead

Alt+F11 to open VB editor, right click 'ThisWorkbook' and insert module and
paste the code below in. In each of the 2 loops in your code add the line

wait(0.08)

the 0.08 gave me a nice smooth scroll but you can play with this.

Sub Wait(DelaySecs As Single)
Dim sngSec As Single
EndDelay = Timer + DelaySecs
Do While Timer < EndDelay
DoEvents
Loop
End Sub

Mike

"MAX" wrote:

I have an animated excel file with a picture rolling from left to right of
the screen. The is done when I click on the picture. My first problem is that
the picture rolls very fast and I want to reduce its speed, and the second
problem is that I want this animation not when I click on the picture but
when I open the file. I am using Excel 2007 and below is the code that I am
using. Any help.

Thanks.

Code:

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

  #10   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default animation

I already have this code in the workbook (see below) and what you mean by
(Adjust the name of the worksheet to match your sheet name.)

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Wait (0.08)
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Wait (0.08)
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub


THANKS.

"Gary''s Student" wrote:

To start your demo automatically, put the following event macro in the
workboook code area:

Private Sub Workbook_Open()
Sheets("Sheet1").Activate
Call StartDemo1
End Sub

Adjust the name of the worksheet to match your sheet name.


Because it is workbook code, it is very easy to install and use:

1. right-click the tiny Excel icon just to the left of File on the Menu Bar
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about Event Macros (workbook code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200841


"MAX" wrote:

Very nice timing, but although I put the the code in the workbook I have
still to click on the picture for the animation, I want this when I open the
file.

Thanks for your great help.

"Mike H" wrote:

Max,

Modify your code like this and note the 2 added lines

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Wait (0.08)
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Wait (0.08)
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

Mike

"MAX" wrote:

Will you please tell me where I am going to put wait(0.08) because I'm a
beginer in VB.

"Mike H" wrote:

Max,

application.wait is a bit of a blunt instrument so try this instead

Alt+F11 to open VB editor, right click 'ThisWorkbook' and insert module and
paste the code below in. In each of the 2 loops in your code add the line

wait(0.08)

the 0.08 gave me a nice smooth scroll but you can play with this.

Sub Wait(DelaySecs As Single)
Dim sngSec As Single
EndDelay = Timer + DelaySecs
Do While Timer < EndDelay
DoEvents
Loop
End Sub

Mike

"MAX" wrote:

I have an animated excel file with a picture rolling from left to right of
the screen. The is done when I click on the picture. My first problem is that
the picture rolls very fast and I want to reduce its speed, and the second
problem is that I want this animation not when I click on the picture but
when I open the file. I am using Excel 2007 and below is the code that I am
using. Any help.

Thanks.

Code:

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub



  #11   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default animation

Will you please write to me the whole code?
Then I click on the Workbook and then I click the drop down near general and
select Workbook, then I write the code. Am I right?
Remember that I am a beginner and sorry for the inconvenience.

Thanks

"Jacob Skaria" wrote:

As mentioned in my earlier post write the code in Workbook_Open()
event

If this post helps click Yes
---------------
Jacob Skaria


"MAX" wrote:

Very nice timing, but although I put the the code in the workbook I have
still to click on the picture for the animation, I want this when I open the
file.

Thanks for your great help.

"Mike H" wrote:

Max,

Modify your code like this and note the 2 added lines

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Wait (0.08)
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Wait (0.08)
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

Mike

"MAX" wrote:

Will you please tell me where I am going to put wait(0.08) because I'm a
beginer in VB.

"Mike H" wrote:

Max,

application.wait is a bit of a blunt instrument so try this instead

Alt+F11 to open VB editor, right click 'ThisWorkbook' and insert module and
paste the code below in. In each of the 2 loops in your code add the line

wait(0.08)

the 0.08 gave me a nice smooth scroll but you can play with this.

Sub Wait(DelaySecs As Single)
Dim sngSec As Single
EndDelay = Timer + DelaySecs
Do While Timer < EndDelay
DoEvents
Loop
End Sub

Mike

"MAX" wrote:

I have an animated excel file with a picture rolling from left to right of
the screen. The is done when I click on the picture. My first problem is that
the picture rolls very fast and I want to reduce its speed, and the second
problem is that I want this animation not when I click on the picture but
when I open the file. I am using Excel 2007 and below is the code that I am
using. Any help.

Thanks.

Code:

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default animation

Launch VBE using short-key Alt+F11. On the left treeview double click 'This
Workbook '. Drop down on the code panel to select Workbook_Open() . Paste the
code there.. This event initiates as soon as you open your workbook.

Post back in case of any queries/

If this post helps click Yes
---------------
Jacob Skaria


"MAX" wrote:

Will you please write to me the whole code?
Then I click on the Workbook and then I click the drop down near general and
select Workbook, then I write the code. Am I right?
Remember that I am a beginner and sorry for the inconvenience.

Thanks

"Jacob Skaria" wrote:

As mentioned in my earlier post write the code in Workbook_Open()
event

If this post helps click Yes
---------------
Jacob Skaria


"MAX" wrote:

Very nice timing, but although I put the the code in the workbook I have
still to click on the picture for the animation, I want this when I open the
file.

Thanks for your great help.

"Mike H" wrote:

Max,

Modify your code like this and note the 2 added lines

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Wait (0.08)
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Wait (0.08)
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

Mike

"MAX" wrote:

Will you please tell me where I am going to put wait(0.08) because I'm a
beginer in VB.

"Mike H" wrote:

Max,

application.wait is a bit of a blunt instrument so try this instead

Alt+F11 to open VB editor, right click 'ThisWorkbook' and insert module and
paste the code below in. In each of the 2 loops in your code add the line

wait(0.08)

the 0.08 gave me a nice smooth scroll but you can play with this.

Sub Wait(DelaySecs As Single)
Dim sngSec As Single
EndDelay = Timer + DelaySecs
Do While Timer < EndDelay
DoEvents
Loop
End Sub

Mike

"MAX" wrote:

I have an animated excel file with a picture rolling from left to right of
the screen. The is done when I click on the picture. My first problem is that
the picture rolls very fast and I want to reduce its speed, and the second
problem is that I want this animation not when I click on the picture but
when I open the file. I am using Excel 2007 and below is the code that I am
using. Any help.

Thanks.

Code:

Sub StartDemo1()
On Error Resume Next
Set OldCell = ActiveCell
ActiveSheet.Shapes("Picture 1").Select
For i = 0 To 360 Step 3
Selection.ShapeRange.IncrementRotation 15
Selection.ShapeRange.Left = Selection.ShapeRange.Left + 10
Selection.ShapeRange.Top = Selection.ShapeRange.Top - 0.1
DoEvents
Next i

For i = 360 To 0 Step -6
Selection.ShapeRange.IncrementRotation -15
Selection.ShapeRange.Left = Selection.ShapeRange.Left - 20
Selection.ShapeRange.Top = Selection.ShapeRange.Top + 0.1
DoEvents
Next i
Selection.ShapeRange.Top = 300
Selection.ShapeRange.Left = 42
OldCell.Select
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Animation filo666 Excel Programming 2 December 29th 05 11:39 PM
Animation Weave New Users to Excel 1 December 7th 05 02:21 PM
animation John Campbell Excel Programming 1 May 5th 05 05:54 PM
animation Libby Excel Programming 1 November 21st 04 10:47 PM
Animation Andy pop Excel Programming 2 November 16th 04 02:41 PM


All times are GMT +1. The time now is 07:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"