Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Moving Object


Reply
 
Thread Tools Display Modes
  #1  
Old 03-25-2009, 03:58 PM
leon896 leon896 is offline
Newcomer
 
Join Date: Mar 2009
Posts: 4
Default Moving Object


I want to make a ball bouncing from left to right when I open an Excel file.
Any help?

Thanks
Reply With Quote
  #2  
Old 03-26-2009, 07:30 AM
tken22 tken22 is offline
Regular
 
Join Date: Feb 2009
Posts: 54
Default

What it sounds like your looking to do is add a splash screen to your excel doc. I was having issues making the background for the form transparent so, scrapping it and just adding a image worked better. Though the correct way is a form, this should get you started. Just add the image using the control box, apply the image in the properties. Run the Bouncing_ball sub, this could be applied to the statup process to run. Make the image visible when it loads then invisible at the end of the sub.

Private Sub Workbook_Open()
'Add the finished code here and it will run each time the workbook is opened.
End Sub

Code:
Public Function Pause(DelayInSeconds As Double)
    Dim StartTime As Double
    StartTime = Timer
    Do While Timer < StartTime + DelayInSeconds
          DoEvents
    Loop
End Function

Sub Bouncing_Ball()

    ActiveSheet.Shapes("Image1").Select
    
    Dim X As Integer
    Dim y As Integer
    Dim z As Integer
    
    For z = 1 To 3
        For X = 30 To 33
            Selection.ShapeRange.IncrementLeft X
            Selection.ShapeRange.IncrementTop X
            Pause (0.15)
        Next
        y = 35
        For X = 30 To 33
            Selection.ShapeRange.IncrementLeft y
            Selection.ShapeRange.IncrementTop -y
            Pause (0.15)
            y = y - 1
        Next
    Next
    
End Sub

Last edited by tken22; 03-26-2009 at 08:03 AM.
Reply With Quote
  #3  
Old 03-26-2009, 12:07 PM
leon896 leon896 is offline
Newcomer
 
Join Date: Mar 2009
Posts: 4
Default

Thank you for your help but I need a little more assistance. Since I never used this type of form, will you please explain to me the process step by step. I will appriciate this help.

Thank you.
Reply With Quote
  #4  
Old 03-26-2009, 05:16 PM
tken22 tken22 is offline
Regular
 
Join Date: Feb 2009
Posts: 54
Default

If I didn't have a screaming baby on my lap I would explain more, but the best advice I can give anyone new to coding is GOOGLE! In this case, try "vba <what your looking for>" and something should come up.

As for the forms, if your going to add a splash screen type form check out this link.

http://www.ozgrid.com/Excel/excel-splash-screen.htm
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->