Can you summarise what you need your timer to do?
The timer() function exists on Mac _ I believe on older versions of Office it "ticked" once per second, but in Office 2011 that seems to be relaxed. Or maybe it's a change in OSX.
Here, I can't make OnTime work, so if you need to schedule a routine to be run, either someone needs to tell you how to make that work, or another approach is needed.
Here, I was able to create and save a stay-open applescript applet that will call a named module at a specified interval, but I wouldn't attempt to use it for real without a lot more understanding and testing. But it is at least one way.
The script:
-- the module we need to run
property module : ""
-- when really idle, only wake up every hour
property really_idle_interval : 3600
-- set this to the smallest interval that can be used
-- (don't know what that actually is)
property smallest_interval : 0.01
-- the current interval. Don't set to 0
property interval : 0
-- set to enable quit
property allow_quit :
true
on run
set
interval to smallest_interval
end run
on starttimer(theModule,
theInterval)
set
allow_quit to false
set
module to theModule
if
interval < smallest_interval then
set
interval to smallest_interval
else
set
interval to theInterval
end
if
end starttimer
to stoptimer()
set
module to ""
set
interval to really_idle_interval
set
allow_quit to true
end stoptimer
on idle
if
module is not "" then
tell
application "Microsoft Word"
run VB macro
macro name module
end
tell
end
if
return
interval
end idle
to reallyquit()
set
allow_quit to true
quit
end reallyquit
-- don't let the user quit from the menu
on quit
if
allow_quit then
continue
quit
end
if
end quit
--end of the Applescript.
You need to save the Applescript as an "Application" with the stay-open after Run handler checked. I called mine "vbatimer" and put it in my Documents folder.
I then put the following test VBA macros in a module called Module1 in Normal and ran "dotimerstuff"
Const appFullName As String = "Macintosh HD:Users:username:Documents:vbatimer.app"
Dim i As Integer
Sub appendtime()
i = i - 1
Debug.Print i
ActiveDocument.Content.InsertParagraphAfter
ActiveDocument.Content.InsertAfter Time()
End Sub
Sub appendtime()
i = i - 1
Debug.Print i
ActiveDocument.Content.InsertParagraphAfter
ActiveDocument.Content.InsertAfter Time()
End Sub
Sub dotimerstuff()
i = 10
Debug.Print MacScript("tell application """ & appFullName & """ to run")
Debug.Print MacScript("tell application """ & appFullName & """ to starttimer(""Normal.Module1.appendtime"",1)")
While i > 0
DoEvents
Wend
Debug.Print MacScript("tell application """ & appFullName & """ to stoptimer()")
i = 10
Debug.Print MacScript("tell application """ & appFullName & """ to starttimer(""Normal.Module1.appendtime"",0.2)")
While i > 0
DoEvents
Wend
Debug.Print MacScript("tell application """ & appFullName & """ to stoptimer()")
Debug.Print MacScript("tell application """ & appFullName & """ to reallyquit()")
End Sub