Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |