[mso] How do I user/simulate a Timer event in Excel

  • From: "John Fejsa" <John.Fejsa@xxxxxxxxxxxxxxxxxxxxxxxx>
  • To: <mso@xxxxxxxxxxxxx>
  • Date: Wed, 18 Aug 2004 09:46:58 +1000

Hi Everyone

I have a very long import procedure that's executed from a menu option. I =
would like to open an "Import" message form and animate a file flying from =
one side of the form (one folder) to the other side (another folder) until =
the import is completed. I can easily do it with other applications but =
find very hard to do with Excel forms, for example when I use Microsoft =
Access, I use a Timer event and move the file fractionally every few =
seconds to simulate the movement. However, Excel forms do not appear to =
have Timer events like Access or VB.=20

I tried to simulate a time event with Excel form but without success; can =
anyone help? I tried various methods with Excel but none worked. "Applicati=
on.OnTime" looks promising but it does not work for me. Below is one =
method I tried for testing (while testing I just tried to show one image =
and hide another). Rather then having " BlinkMover" procedure executing =
every second as expected, the procedure acually executes only once (only =
when the calling "OpenSession" procedure is finished, defeats the reason =
for using the timer...)

Any help would be greatly appreciated.

Global variable=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Public fBlinkMover As Boolean 'used with OPSES form to indicate whether to =
blink
Public dTime 'Used to set time when to fire BlinkMover Procedure

Procedures
=3D=3D=3D=3D=3D=3D=3D=3D=3D
Public Sub OpenSession()
=20
        strFileToOpen =3D Application.GetOpenFilename("Workbook (*.xls), =
*.xls", , "Open your existing AIP session")
  =20
        If strFileToOpen <> False Then
'START Blinking
                fBlinkMover =3D True 'Start BLINKING
                OPSES.Show 'Opne OPSES form - this form only has two =
images at the moment (imgPic1 and imgPic2
                DoEvents
                dTime =3D Now + TimeValue("00:00:01") 'Set time to one =
second from now
                Application.OnTime dTime, "BlinkMover" 'Instruct the =
application to run "BlinkMover" procedure one second from now
  =20
...Do other work here...

                Workbooks.Open Filename:=3DstrFileToOpen
        =09
                Sheets("Original_data").Select

*Deleted code to make the procedure shorter for this email
*Etc, etc, etc...

'STOP Blinking
                fBlinkMover =3D False 'Stop BLINKING * this will also stop =
BlinkMover procedure calling itself
                OPSES.Hide 'Hide OPSES form
  =20
                Sheets("Results").Select
  =20
                MsgBox ("AIP session has now been opened")

        Else
                'User did not open
        End If


End Sub


Public Sub BlinkMover()
        If fBlinkMover Then 'Only execute if fBlinkMover is set to TRUE
                opses!imgPic1.Visible =3D Not opses!imgPic2.Visible =
'Reverse visiblitiy (Show/Hide)
                opses!imgPic2.Visible =3D Not opses!imgPic1.Visible =
'Reverse visiblitiy (Show/Hide)
                opses.Repaint
                DoEvents
                dTime =3D Now + TimeValue("00:00:01") 'Add another second =
to dTime
                Application.OnTime dTime, "BlinkMover" 'Call BlinkMover =
procedure again in one second
        End If
End Sub


Thanks for your suggestions.


John Fejsa
Senior Systems Analyst/Computer Programmer
Hunter Population Health
Locked Bag 10, WALLSEND NSW 2287
Phone: (02) 4924 6336 Fax: (02) 4924 6209
john.fejsa@xxxxxxxxxxxxxxxxxxxxxxxx
www.hcha.org.au

The doors we open and close each day decide the lives we live.

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in 
the subject line.

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts:

  • » [mso] How do I user/simulate a Timer event in Excel