Developing an Excel Add-in with a Timer that Accounts for Visibility Changes

Simran Sharma 0 Reputation points
2024-09-12T11:18:02.64+00:00

I am creating an Excel add-in using React and Office.js that tracks the amount of time a user spends working in an Excel sheet. I want the timer to pause when the Excel window is minimized or when the user switches to another window or tab, but it continues to run even when the Excel window is inactive.

Steps to Reproduce:

  1. Build an Excel add-in with React that includes a timer that increments every second to track the time spent working in Excel.
  2. Detect when the document.visibilitychange event occurs and pause the timer when the window is minimized or when the user switches to another window or tab.
  3. Start the timer, open the add-in in Excel, and then minimize the Excel window or switch to another application/tab.

Expected Behavior:

The timer pauses when the Excel window is minimized or when the user switches to another application or tab, and resumes when Excel regains focus or becomes active again.

Actual Behavior:

The timer continues to run even when the Excel window is minimized or the user switches to another application. The visibilitychange event does not detect when the Excel window becomes inactive in the add-in context.

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
1,002 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,020 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.