IeTimer !

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
9,641
Office Version
  1. 2016
Platform
  1. Windows
Hi,


Has anyone used the IeTimer Object before ?

I am interested to see a Small/Simple sample code using it in order to get a feel for it.

Regards.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Use the ietimer in a Sheet to say update a Time
say a Clock.......fairly straight forward......


IeTimer > Insert in Sheet

Sheets Code

Code:
Option Explicit
'// Placed in the Active sheet where the Timer is housed
Private Sub IeTimer1_Timer()
   [B2] = Format(Now, "dd/mm/yyyy hh:mm:ss")
End Sub

Module code

Code:
'//  Placed in a STD Module
Option Explicit
Dim objTm As Object

Sub StopTimer()
   Set objTm = Sheet1.OLEObjects("Ietimer1")
   objTm.Object.Enabled = False
End Sub

Sub StartTimer()
    Set objTm = Sheet1.OLEObjects("Ietimer1")
    With objTm.Object
        'Set timer @ 1 sec
        .Interval = 1
        .Enabled = True
    End With
End Sub

That's it.....clicking on the button starts the cell up date > Clock........
 
Upvote 0
Thanks for the input Ivan,

The code works apart from two problems:

1- Everytime I select a Cell in the worksheet, I get a RunTime error("Method Evaluate Of Object WorkSheet Failed"). I had to add an On Error Resume Next Statement to avoid this error.

2- the moment I exit Design Mode(After embeeding the Timer Control),The IETimer Control strangely disappears and is no longer visible on the worksheet layer or reappears but remains disabled!! :eek:

Is this Control supposed to behave like that ??

Also, what is the point of having a Control on a worksheet if the User can't interact with it ?

In order to avoid using an embeeded IETimer Control altogether I tried establishing a rederence to the IETimer Object Via Tools\References in the VBEditor and trap this object's event by means of a Class Module as follows:

This code goes in the Class Module TimerClass


<font face=Courier New><SPAN style="color:#00007F">Public</SPAN> <SPAN style="color:#00007F">WithEvents</SPAN> Tmr <SPAN style="color:#00007F">As</SPAN> IeTimer

<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Tmr_Timer()
    [B2] = Format(Now, "dd/mm/yyyy hh:mm:ss")
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>


This code goes in a Standard Module:


<font face=Courier New><SPAN style="color:#00007F">Public</SPAN> TmrObject <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">New</SPAN> TimerClass

<SPAN style="color:#00007F">Sub</SPAN> StartTimer()
    <SPAN style="color:#00007F">Set</SPAN> TmrObject.Tmr = <SPAN style="color:#00007F">New</SPAN> IeTimer
    TmrObject.Tmr.Interval = 1
    TmrObject.Tmr.Enabled = ValTrue
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>

<SPAN style="color:#00007F">Sub</SPAN> StopTimer()
    TmrObject.Tmr.Enabled = ValFalse
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>


Although the above codes seem very correct to me, for some reason, when I run the StartTimer Sub, Cell B2 doesn't update which means the code doesn't work !!

I just can't spot what I may be doing wrong ! :x


I hope you can find out what the problem is.

Looking forward to hearing from you.
 
Upvote 0

Forum statistics

Threads
1,215,949
Messages
6,127,877
Members
449,410
Latest member
adunn_23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top