ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Animating a Menu Bar (https://www.excelbanter.com/excel-programming/343540-animating-menu-bar.html)

Jan G. Thorstensen

Animating a Menu Bar
 
Hi. I want to animate a menu bar that is floating in Excel and flies in from
left to right.

This is the code where I attemped to do it, but the screen isn't updated
properly.
How can I have a better visual look here. Thanks for helping.

CODE SNIPPET:
------------------



Sub MENU_Makro3()
Dim myBar As CommandBar
Dim i As Integer
'
Set myBar = CommandBars("My Menu")
With myBar
.Position = msoBarFloating
.Top = 245
' Wants to animate the menu bar flying in from Left
For i = 35 To 600
.Left = i
Next i
End With
' Unfortuneately you can hardly se the Menu Bar moving. Why is that???
End Sub


Regards
Jan



Jim Rech

Animating a Menu Bar
 
This is better:

Sub MENU_Makro3()
Dim myBar As CommandBar
Dim i As Integer
Set myBar = CommandBars("My Menu")
With myBar
.Position = msoBarFloating
.Top = 245
DoEvents
For i = 35 To 600
.Left = i
DoEvents
Next i
End With
End Sub


--
Jim
"Jan G. Thorstensen" wrote in message
...
Hi. I want to animate a menu bar that is floating in Excel and flies in
from left to right.

This is the code where I attemped to do it, but the screen isn't updated
properly.
How can I have a better visual look here. Thanks for helping.

CODE SNIPPET:
------------------



Sub MENU_Makro3()
Dim myBar As CommandBar
Dim i As Integer
'
Set myBar = CommandBars("My Menu")
With myBar
.Position = msoBarFloating
.Top = 245
' Wants to animate the menu bar flying in from Left
For i = 35 To 600
.Left = i
Next i
End With
' Unfortuneately you can hardly se the Menu Bar moving. Why is that???
End Sub


Regards
Jan




[email protected]

Animating a Menu Bar
 
I think your menu is just not having enough time to redraw itself.
Play with the iPauseTime to adjust how fast the menu moves. I also
added a Step in your For..Next statement that can adjust the speed of
the animation.

Sub MENU_Makro3()
Dim myBar As CommandBar
Dim i As Integer
Dim iPauseTime
Dim iStart

iPauseTime = 0.01
Set myBar = CommandBars("My Menu")
With myBar
.Position = msoBarFloating
.Top = 245
' Wants to animate the menu bar flying in from Left

For i = 35 To 600 Step 4
iStart = Timer
Do While Timer < iStart + iPauseTime
DoEvents ' Yield to other processes.
Loop
.Left = i
Next i
End With
End Sub
Regards
Jan



Jan G. Thorstensen

Animating a Menu Bar
 
Thanks a lot, Jim Rech. That did the trick!

Jan



"Jim Rech" skrev i melding
...
This is better:

Sub MENU_Makro3()
Dim myBar As CommandBar
Dim i As Integer
Set myBar = CommandBars("My Menu")
With myBar
.Position = msoBarFloating
.Top = 245
DoEvents
For i = 35 To 600
.Left = i
DoEvents
Next i
End With
End Sub


--
Jim
"Jan G. Thorstensen" wrote in message
...
Hi. I want to animate a menu bar that is floating in Excel and flies in
from left to right.

This is the code where I attemped to do it, but the screen isn't updated
properly.
How can I have a better visual look here. Thanks for helping.

CODE SNIPPET:
------------------



Sub MENU_Makro3()
Dim myBar As CommandBar
Dim i As Integer
'
Set myBar = CommandBars("My Menu")
With myBar
.Position = msoBarFloating
.Top = 245
' Wants to animate the menu bar flying in from Left
For i = 35 To 600
.Left = i
Next i
End With
' Unfortuneately you can hardly se the Menu Bar moving. Why is that???
End Sub


Regards
Jan







All times are GMT +1. The time now is 06:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com