Excel Effect – Using Excel to create great things

Excel Effect – Using Excel to create great things

Excel Effect - Using Excel to create great things

Excel Effect – Using Microsoft Excel (or Excel) to create great things.

Showing off the Excel effect

This page shows you some of the great things that we do in Excel. Moreover, it will inspire you to create Excel effects of your own. Now, these examples will be either in video form or an image.

The flying spaceship

So, we wanted to see how smooth animation works in Excel. On the whole, our spaceship flys okay. However, we are not quite sure if we will expand on it in Excel.

The code

Here is the code for the spaceship demo.

Public scrWidth   As Single                             'screen width
Public shipHeight As Single                             'spaceship height
Public shipWidth  As Single                             'spaceship width

'GameElements
'   Define game elements
'   Note: Use Private keyword for Type declarations within
'         a class module
Private Type GameElements
    x      As Single            'horizontal position
    y      As Single            'vertical position
    height As Single            'height
    width  As Single            'width
End Type


Sub End_Program()
    

    Shapes("objSpaceshipRTL").Visible = msoFalse
    Shapes("objSpaceshipLTR").Visible = msoFalse
    
    Shapes("objSpaceshipRTL").Visible = msoTrue
    
    End
End Sub

Function Pause(numberOfSeconds As Variant)
    On Error GoTo Error_Goto                            'in case an error occurs
                                                        
    Dim pauseTime As Variant                            'pause time
    Dim startTime As Variant                            'start time
    Dim elapsed   As Variant                            'elapsed time
    
    pauseTime = numberOfSeconds                         'set pause time
    startTime = Timer                                   'get current time
    elapsed = 0                                         'initialize elapsed time
    
    Do While (Timer < startTime + pauseTime)
        elapsed = elapsed + 1                           'increment elapsed time
        
        If (Timer = 0) Then                             'check timer
            'Crossing midnight
            
            pauseTime = pauseTime - elapsed             'decrement pause time by elapsed time
            startTime = 0                               'reset start time
            elapsed = 0                                 'reset elapsed time
        End If
        
        DoEvents                                        'allow time for other operations
    Loop
    
Exit_Goto:
    On Error GoTo 0
    Exit Function
Error_Goto:
    Debug.Print Err.Number, Err.Description, Er1
    GoTo Exit_Goto
End Function

Sub sbtnStart_Click()

    scrWidth = Application.ActiveWindow.VisibleRange.width  'assign width of visible range
    shipHeight = Shapes("objSpaceshipRTL").height           'assign ship's height
    shipWidth = Shapes("objSpaceshipRTL").width             'assign ship's width
    
    Shapes("objSpaceshipLTR").Visible = msoFalse            'hide left-to-right ship
    Shapes("objSpaceshipRTL").Left = 823                    'set left (x) position of ship
    Shapes("objSpaceshipRTL").Top = 112.5                   'set top (y) position of ship
    
    Start_Flight
End Sub

Sub Start_Flight()
    'Debug.Print Shapes("objSpaceshipRTL").Left
    'Debug.Print Shapes("objSpaceshipRTL").Left
    'Debug.Print scrWidth
    '112.5
    '2.25
    Debug.Print d
    
    Shapes("objSpaceshipRTL").Visible = msoFalse
    Shapes("objSpaceshipLTR").Visible = msoFalse
    
    For yPos = 112.5 To 2.25 Step -0.25
    
    
    Next
    
    Do
        For xPos = 823 To 0 Step -3
            Shapes("objSpaceshipRTL").Visible = msoTrue
            
            yInc = Int(1 * Rnd * 2)
            
            If (yInc = 0) Then
                yPos = Shapes("objSpaceshipRTL").Top + 1
                
                If yPos > 112.5 Then yPos = 112.5
            Else
                yPos = Shapes("objSpaceshipRTL").Top - 1
                
                If yPos < 2.25 Then yPos = 2.25
            End If
            
            Pause 0.005
            
            Shapes("objSpaceshipRTL").Left = xPos
            Shapes("objSpaceshipRTL").Top = yPos
            
            Shapes("objSpaceshipRTL").Visible = msoFalse
        Next
        
        Shapes("objSpaceshipRTL").Visible = msoFalse
        
        For xPos = xPos To 823 Step 3
            Shapes("objSpaceshipLTR").Visible = msoTrue
            
            yInc = Int(1 * Rnd * 2)
            
            If (yInc = 0) Then
                yPos = Shapes("objSpaceshipLTR").Top + 1
                
                If yPos > 112.5 Then yPos = 112.5
            Else
                yPos = Shapes("objSpaceshipLTR").Top - 1
                
                If yPos < 2.25 Then yPos = 2.25
            End If
            
            Pause 0.005
            
            Shapes("objSpaceshipLTR").Left = xPos
            Shapes("objSpaceshipLTR").Top = yPos
            
            Shapes("objSpaceshipLTR").Visible = msoFalse
        Next
    Loop
    
    Shapes("objSpaceshipRTL").Visible = msoTrue
End Sub
 

Affiliate stuff – Move up and excel with Excel