Clock 
Author Message
 Clock

Is it possible to embed a digital clock from a third party
within an excel spreadsheet. I have a third party clock
program which I would like to have attached to a
spreadsheet and which will open and close with the
spreadsheet.

Could anyone help please.
Thankyou,
Rick



Fri, 25 Nov 2005 04:06:22 GMT  
 Clock
What sort of information do you have from the third party about such use? Maybe they can tell
you how to do this.
Quote:

>Is it possible to embed a digital clock from a third party
>within an excel spreadsheet. I have a third party clock
>program which I would like to have attached to a
>spreadsheet and which will open and close with the
>spreadsheet.

>Could anyone help please.
>Thankyou,
>Rick



Fri, 25 Nov 2005 04:32:27 GMT  
 Clock
It's an old freeware executable file which I can run and
then place on top of the desktop for the current session.
However, I was wondering if this file can be associated
with my spreadsheet and opened and closed with it. I only
need it for one particular spreadsheet.
Any other clues?
Thanks for your reply
Rick

Quote:
>-----Original Message-----
>What sort of information do you have from the third party

about such use? Maybe they can tell
Quote:
>you how to do this.

>On Sun, 8 Jun 2003 20:06:22 -0700, "Rick"

>>Is it possible to embed a digital clock from a third
party
>>within an excel spreadsheet. I have a third party clock
>>program which I would like to have attached to a
>>spreadsheet and which will open and close with the
>>spreadsheet.

>>Could anyone help please.
>>Thankyou,
>>Rick

>.



Fri, 25 Nov 2005 12:39:44 GMT  
 Clock
You could use the workbook_open event to run a shell statement that executes
the clock program, but you would probably have to go to the windows API to
close it.

Regards
Tom Ogilvy


Quote:
> It's an old freeware executable file which I can run and
> then place on top of the desktop for the current session.
> However, I was wondering if this file can be associated
> with my spreadsheet and opened and closed with it. I only
> need it for one particular spreadsheet.
> Any other clues?
> Thanks for your reply
> Rick

> >-----Original Message-----
> >What sort of information do you have from the third party
> about such use? Maybe they can tell
> >you how to do this.

> >On Sun, 8 Jun 2003 20:06:22 -0700, "Rick"

> >>Is it possible to embed a digital clock from a third
> party
> >>within an excel spreadsheet. I have a third party clock
> >>program which I would like to have attached to a
> >>spreadsheet and which will open and close with the
> >>spreadsheet.

> >>Could anyone help please.
> >>Thankyou,
> >>Rick

> >.



Fri, 25 Nov 2005 13:02:00 GMT  
 Clock
Rick,

Is this any good for you? It allows you to run a clock in the worksheet or
in the status bar

Put this is a normal; code module

Option Explicit

Private Declare Function FindWindow Lib "user32" _
    Alias "FindWindowA" _
   (ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long

Private Declare Function SetTimer Lib "user32" _
   (ByVal hWnd As Long, _
    ByVal nIDEvent As Long, _
    ByVal uElapse As Long, _
    ByVal lpTimerFunc As Long) As Long

Private Declare Function KillTimer Lib "user32" _
   (ByVal hWnd As Long, _
    ByVal nIDEvent As Long) As Long

Private Declare Function GetCurrentVbaProject Lib "vba332.dll" _
    Alias "EbGetExecutingProj" _
   (hProject As Long) As Long

Private Declare Function GetFuncID Lib "vba332.dll" _
    Alias "TipGetFunctionId" _
   (ByVal hProject As Long, _
    ByVal strFunctionName As String, _
    ByRef strFunctionID As String) As Long

Private Declare Function GetAddr Lib "vba332.dll" _
    Alias "TipGetLpfnOfFunctionId" _
   (ByVal hProject As Long, _
    ByVal strFunctionID As String, _
    ByRef lpfnAddressOf As Long) As Long

Public ClockView As String

Private WindowsTimer As Long

Public Function fncWindowsTimer(TimeInterval As Long) As Boolean
Dim WindowsTimer As Long
    WindowsTimer = 0
    'if we are in Excel2000 or above use the
    'built-in AddressOf operator to get a pointer to the
    'callback function
    If Val(Application.Version) > 8 Then
        WindowsTimer = SetTimer(hWnd:=FindWindow("XLMAIN",
Application.Caption), _
                                nIDEvent:=0, _
                                uElapse:=TimeInterval, _
                                lpTimerFunc:=AddrOf_cbkCustomTimer)
    Else 'use K.Getz & M.Kaplan function to get a pointer
        WindowsTimer = SetTimer(hWnd:=FindWindow("XLMAIN",
Application.Caption), _
                                nIDEvent:=0, _
                                uElapse:=TimeInterval, _
                                lpTimerFunc:=AddrOf("cbkCustomTimer"))
    End If

    fncWindowsTimer = CBool(WindowsTimer)

End Function

Public Function fncStopWindowsTimer()
    KillTimer hWnd:=FindWindow("XLMAIN", Application.Caption), _
              nIDEvent:=WindowsTimer
End Function

Private Function cbkCustomTimer(ByVal Window_hWnd As Long, _
                                ByVal WindowsMessage As Long, _
                                ByVal EventID As Long, _
                                ByVal SystemTime As Long) As Long
Dim CurrentTime As String
    On Error Resume Next
    If ClockView = "Status Bar" Then
        Application.StatusBar = Format(Now, "Long Time")
    Else
        Range("clock").Value = Format(Now, "Long Time")
    End If
End Function

Private Function AddrOf(CallbackFunctionName As String) As Long
'AddressOf operator replacement for Office97 VBA
'Authors: Ken Getz and Michael Kaplan
Dim aResult As Long
Dim CurrentVBProject As Long
Dim strFunctionID As String
Dim AddressOfFunction As Long
Dim UnicodeFunctionName As String

    'convert the name of the function to Unicode system
    UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)

    'if the current VBProjects exists...
    If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then
        '...get the function ID of the callback function, based on its
        'unicode-converted name, in order to ensure that it exists
         aResult = GetFuncID(hProject:=CurrentVBProject, _
                             strFunctionName:=UnicodeFunctionName, _
                             strFunctionID:=strFunctionID)
        'if the function exists indeed ...
        If aResult = 0 Then
            '...get a pointer to the callback function based on
            'the strFunctionID argument of the GetFuncID function
             aResult = GetAddr(hProject:=CurrentVBProject, _
                               strFunctionID:=strFunctionID, _
                               lpfnAddressOf:=AddressOfFunction)
            'if we've got the pointer pass it to the result of the function
            If aResult = 0 Then
                AddrOf = AddressOfFunction
            End If

and this code to start it in another module
Option Explicit

Private oldStatusBar

Sub StartClock()
    If ClockView = "Status Bar" Then
        oldStatusBar = Application.DisplayStatusBar
        Application.DisplayStatusBar = True
        Application.StatusBar = Format(Now, "Long Time")
    Else
        Range("clock").Value = Format(Now, "Long Time")
    End If
    fncWindowsTimer 1000
End Sub

Sub StopClock()
    fncStopWindowsTimer
    If ClockView = "Status Bar" Then
        Application.StatusBar = False
        Application.DisplayStatusBar = oldStatusBar
    End If
End Sub
       End If

   End If

 End Function

 Private Function AddrOf_cbkCustomTimer() As Long
'Office97 VBE does not recognise the AddressOf operator;
'however, it does not raise a compile-error either...
    AddrOf_cbkCustomTimer = vbaPass(AddressOf cbkCustomTimer)
 End Function

 Private Function vbaPass(AddressOfFunction As Long) As Long
    vbaPass = AddressOfFunction
 End Function

I have buttons on a worksheet to start and stop the timer, with option
buttons to identify whether worksheet or status bar, and this is that code

Private Sub cmdStartClock_Click()
    Range("C1").Value = Format(time, "hh:mm:ss")
    StartClock
End Sub

Private Sub cmdStopClock_Click()
    StopClock
End Sub

Private Sub optCell_Click()
    ClockView = "Cell"
End Sub

Private Sub optStatus_Click()
    ClockView = "Status Bar"
End Sub

--
    HTH

    -------

    Bob Phillips
    ... looking out across Poole Harbour to the Purbecks


Quote:
> It's an old freeware executable file which I can run and
> then place on top of the desktop for the current session.
> However, I was wondering if this file can be associated
> with my spreadsheet and opened and closed with it. I only
> need it for one particular spreadsheet.
> Any other clues?
> Thanks for your reply
> Rick

> >-----Original Message-----
> >What sort of information do you have from the third party
> about such use? Maybe they can tell
> >you how to do this.

> >On Sun, 8 Jun 2003 20:06:22 -0700, "Rick"

> >>Is it possible to embed a digital clock from a third
> party
> >>within an excel spreadsheet. I have a third party clock
> >>program which I would like to have attached to a
> >>spreadsheet and which will open and close with the
> >>spreadsheet.

> >>Could anyone help please.
> >>Thankyou,
> >>Rick

> >.



Fri, 25 Nov 2005 16:52:27 GMT  
 Clock
Thanks all, for your help.
Regards
Rick


Sat, 26 Nov 2005 05:01:24 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Need to set my clock in dos ? Fixed the WScript/kak bug... but now the clock

2. Outlook Clock Inaccuracies

3. clock

4. Issues with my clock

5. Clock

6. How to set clock on Outlook Explorer

7. Outlook Time Zone not in sync w/system clock

8. outlook express clock/time settings for messages

9. out of timezone email makes clock lose time

10. Clock Thing


 
Powered by phpBB® Forum Software © phpBB Group