VBA Timer Events Suspend When Cursor is Positioned at the Start of Inline Math Zones
- Dominant language
- VBA
- Stars
- 7
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
## Description
When using the Equation Editor in Word 365, VBA timer events unexpectedly suspend their execution when the cursor is positioned at the very beginning of an inline math zone (immediately after entering the math zone).

The timer events resume normal execution when either:
- Moving the cursor outside the math zone, or
- Moving the cursor further inside the math zone
A video demo of this behavior is available at: [Video: VBA script gets suspended when the input cursor is at the beginning of an inline OMath expression (2 minutes)](https://iu.mediaspace.kaltura.com/media/t/1_xyjpxxom)
This behavior does not occur with display math zones, only inline math zones.
## Steps to Reproduce
1. Create a Word document with an inline math expression (e.g., $`\sqrt{x+5}`$)
2. Add a VBA timer that runs periodic events (example code below)
3. Use the Immediate Window (Ctrl+G) or other means to monitor the timer
4. Run the VBA code to start the timer
5. Position the cursor at different locations:
- Just before the math zone (timer runs normally)
- At the very beginning of the math zone; editor visible & in front of expression (timer suspends)
- Further inside the math zone (timer resumes)
- Outside the math zone (timer runs normally)
## Example Code
```vb
Dim lnCounter As Long
Dim blnEnableCounter As Boolean
Dim dtNextTime As Date
Const INTERVAL_SECONDS As Double = 0.1 ' 1/10th of a second
Sub startCounting()
blnEnableCounter = True
lnCounter = 0
count
End Sub
Sub stopCounting()
blnEnableCounter = False
End Sub
Sub count()
If blnEnableCounter = True Then
lnCounter = lnCounter + 1
Debug.Print lnCounter
' Schedule the next count
dtNextTime = Now + (INTERVAL_SECONDS / 86400) ' Convert seconds to days
Application.OnTime When:=dtNextTime, Name:="count"
End If
End Sub
```
# Tested Version Information
## Windows OS
OS Version:
-- OS Name: Microsoft Windows 11 Enterprise
-- Version: 10.0.22621 Build 22621
-- Locale: United States
Microsoft Word Version:
-- Microsoft 365 Apps for enterprise
-- Version 2410 (Build 18129.20158 Click-to-Run) Current Channel
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.