Office Add-ins deployment
29 TopicsProgrammatically set the cursor (caret) to a specific location in an e-mail
Describe your scenario We are writing an addin for One Outlook where we place a signature text in the body of an e-mail. What is the problem to solve? The signature text we are placing is added correctly, but the cursor (caret) is placed at the bottom of the inserted text. We would like to control where the cursor (caret) is placed after we inserted the text. We have tried the following ideas: Using setSelectedDataAsync to dynamically insert content immediately after the marker. Manipulating the HTML with getAsync and setAsync to simulate the desired cursor position. Adding selectable elements, such as a span with a zero-width space, to force the cursor to position itself at the marker. Using prependAsync to insert content at the beginning of the body as an alternative to controlling the cursor. Implementing JavaScript methods like this: function setCaret() { var el = document.getElementById("editable"); var range = document.createRange(); var sel = window.getSelection(); range.setStart(el.childNodes[2], 5); range.collapse(true); sel.removeAllRanges(); sel.addRange(range); } Which APIs or add-in features? We are using Office.JS, see Insert data at the current cursor position We have asked this question here , but this feature isn't available. Can this feature be added? There is a more or less similar question here.Automated NLP conversational agent production, with Office, without writing code
I have developed a solution which allows people to create Natural Language conversational agents, using MS Office and VBA, without writing any line of code. The method starts with MS Word. The integrated VBA code extract patterns from Docx documents. MS Excel get back these patterns and through its VBA capabilities, produce after few clicks (fully automated process) a Graphed Conversational Agent that I can query in Natural Language to find the right answer : from MS word documents to MS Excel queries in few clicks. I plan also to automate another use case which is Text Analytics document comparizon.Implement Office.context.mailbox.item.getAsFileAsync for draft messages
We have a requirement in an Office.js add-in to do the following: Automatically send a message Save the sent message The functionality was previously implemented using EWS and Office.context.mailbox.getCallbackTokenAsync. However, both are being phased out. Office.auth.getAccessToken is supposed to replace Office.context.mailbox.getCallbackTokenAsync, but we did not manage to get it to work in my add-in. To send the mail, Office.context.mailbox.item.sendAsync is now available, but it currently does not allow to execute code after sending. So we want to collect the draft before sending and process it in the back-end of our web app. We are hindered here by the fact that Office.context.mailbox.item.getAsFileAsync cannot be used on a draft. The function is currently not available for a draft message, we get the error message `Office.context.mailbox.item.getAsFileAsync is not a function` when trying to use it. The same works fine for messages in other Outlook folders like Inbox or Sent Items. To assemble eml-like text for the draft message so that we can save it in the back end of our add-in requires quite a lot of code. Also, img nodes reference external content, e.g., they have a src like `src="https://attachments.office.net/owa/.../service.svc/s/GetAttachmentThumbnail?id=` with id being a base64 string, where an eml should have `src="cid:` with cid referencing to a short id of a mime part in the same eml. There is no straightforward way to resolve all images when building an eml client-side.How to get current page number and the total page count of a document using Word Add-in office.js
I would like to inquire if there is a method or feature available in Office.js for programmatically obtaining the current page number and the total page count of a document. Specifically, I am interested in accessing this information within the Microsoft Word application. Additionally, if such a feature is not currently available, do you have any plans or information regarding the potential release of this feature in the future? It's worth noting that our organization does not use OneDrive for any operations. Here are the details of my environment: Platform: PC desktop Host Application: Microsoft Word Office Version: Microsoft Word for Microsoft 365 MSO (Version 2304 Build 16.0.16327.20200) 64-bit Operating System: Windows 10 Pro Thank you for your assistance.Enhanced Document Control/Protection APIs in Office.js for Word Add-ins
We are developing a Word add-in using Office.js and JavaScript APIs. Our use case requires advanced document control features, which are currently challenging to achieve within the existing Office.js framework. Here’s our feature request: Proposed Functionality: Based on the defined custom properties on a document via add-ins, provide APIs/commands/hooks to disable or override Word's default 'Save,' 'Save As,' and 'Share' options to prevent users from saving or sharing the document locally. Introduce additional APIs for implementing custom protection mechanisms within the add-in. Current Challenges: Achieving this functionality appears possible through VSTO add-ins, but they are not compatible with Office.js solutions. VSTO/.NET commands require complex workarounds, such as creating a separate .NET server to communicate with Office.js, which adds development complexity and affects efficiency. Request: We would greatly appreciate the introduction of built-in, efficient APIs in Office.js to handle document protection and control scenarios seamlessly without relying on external frameworks or services. This would significantly enhance the capability of modern web-based add-ins and improve the development experience for Word add-in developers.Extend OfficeExtension.EventHandlerResult API
Notice: this would benefit all Apps for Office Addins that expose events with OfficeExtension.EventHandlerResult<>. Currently, when adding an event handler to Excel.Table.onSelectionChanged, the returned OfficeExtension.EventHandlerResult object is only valid within the current JavaScript session. If the session is lost (e.g., due to add-in reload, debugging, or errors), there is no way to retrieve and remove previously attached event handlers. This leads to "zombie" event handlers accumulating in an Excel session, particularly during development. While removeAll() is an option, it indiscriminately removes all handlers, including those registered by other add-ins, which is not ideal. There is no way to enumerate existing event handlers attached to an event. There is no way to retrieve a reference to a previously attached handler after the session is lost. There is no unique ID assigned to handlers that would allow selective removal. I propose adding an API to manage event handlers more effectively, such as: Retrieve a list of active handlers for a given event (getHandlers() method). Assign unique, retrievable IDs to event handlers, allowing for selective removal (removeById(id)).Extension should grab focus when opened
When opening a task-pane based extension, the page that is loaded should automatically be granted (or have an option to automatically grant) keyboard focus. This would save our users clicks, as the workflow is: open the extension with a button from the Ribbon click into the extension's pane use the keyboard to navigate options / use hotkeys to make selections28Views2likes0CommentsWorksheet OnChanged event should return details when multiple cells are edited same as single cell
Description I am using the Worksheet.OnChanged event in office.js to capture valueBefore and valueAfter for cell changes. When I change a single cell, the event provides the details object with changeType: "RangeEdited" along with valueBefore and valueAfter. However, when I edit multiple cells at once (e.g., deleting/copy-pasting values into a range), the details object is undefined. This makes it impossible to track value changes for multiple-cell edits. Below is a screenshot showing both scenarios. Expected behavior The details object should provide valueBefore and valueAfter for all modified cells, similar to how it works for a single cell. Current behavior For multiple-cell edits, details is undefined, making it impossible to track the changes. Steps to reproduce Register Worksheet.OnChanged event to capture valueBefore and valueAfter. Modify a single cell → details contains valueBefore and valueAfter. Modify multiple cells at once (e.g., delete a range of values) → details is undefined. Useful logs Here are screenshots when using the Worksheet.OnChanged event: When "RangeEdited" in a single cell: When "RangeEdited" in multiple cells or range: Purpose of submission This concern is raised because when using Excel's built-in Review → Show Changes, it correctly tracks before and after values for the same range "CD:C4". Useful Links Bug reported on office.js GitHub: https://github.com/OfficeDev/office-js/issues/5347Find all installed JS add-ins via the Office JS API
Currently the only way to determine the JavaScript add-ins installed in Excel, Word, or PowerPoint is to navigate to either of the following menu items: File > Get Add-ins > Office Add-ins Home > Add-ins > More Add-ins > Office Add-ins Under 'Office Add-ins' you can select 'My Add-ins', 'My Organization', and/or 'Admin Managed' to find the JavaScript add-ins installed, and how they were deployed. It would also be helpful to enhance the Office JavaScript API so you can: Get back a list of all installed JavaScript add-ins Get back a list of all installed JavaScript add-ins categorized/bucketed by 'My Add-ins', 'My Organization', and/or 'Admin Managed' We have seen instances where a JavaScript add-in exist under 'My Add-ins' and 'Admin Managed' as the user initially installs the add-in, but then the IT deploys the add-in. Get back any metadata like the version, install/update date, etc. Provide a specific add-in name get back if installed, how it was installed: 'My Add-ins', 'My Organization', and/or 'Admin Managed', and any metadata that can be included like version, install/update date, etc. Offering this feature via the Office JavaScript API would allow for installed applications and troubleshooting tools to be able to quickly and easily gather this information to determine if the JavaScript add-in has already been installed notify the user when the JavaScript add-in is already installed vs when it still needs to be installed debug issues or other vendor add-in conflicts identify equivalent add-ins that may both be installed (COM/XLL/Automations vs. JavaScript add-ins) Microsoft could potentially leverage this Office JavaScript API enhancement to display JavaScript add-ins within Desktop Office apps under File > Options > Add-ins. This would allow users to see their legacy and JavaScript add-ins in one single location.147Views11likes0Comments