Detect hover in Microsoft Word Add-In - ms-word

I'm trying to develop an Add-In for Microsoft Word. The basic idea being to load some key words into the document and then when the user hovers over one of the key words a box pops up to show more information, like on Wikipedia or Facebook.
Looking over the api reference I see that the popup box isn't possible, and that's okay I could just make it appear in the Add-In's panel.
I read about bindings, but it seems they can't detect a hover or even a click event? I thought about hacking something together with links but I don't think that would be very UI friendly.
The only thing I can think of to make it kind of possible is to have the user manually highlight the key word (sometimes the key word is more than one word), then have them click a "search" button in the Add-In's panel that would read the selected range and compare it against a database of words. It just seems very anti user compared to the original idea.
Does anyone know of a better way to achieve this?

Related

Can I tag text for meaning using TinyMCE or some other rich text editor?

I'm not sure what this functionality or feature is technically called. I just tried asking the chat on their homepage and they suggested I try asking here to see if anyone else has done this.
We're looking to allow users to highlight text and connect a tag to that text so that it can be categorized and found in a search later on, or used in analytics. For example, if the highlighted text says, "His leadership skills were average," the user should be able to highlight that text and be offered to tag it with pre-built tags, in this case perhaps "leadership" and "neutral". That way a separate user can search for those tags later. What would this functionality be called?

How can I format text without changing document state in MSWord web add-in API?

I'm developing an add-in for MSWord using Microsoft web add-in API. I'd like to underline or highlight some given words, but only in the scope of that session. I don't want to change the document's state. In other words, I don't want to persist the new text formatting when the document is saved.
I know how to format text, but the document's state is changed. I have this code at the moment:
word_range.font.underline = Word.UnderlineType.wave;
I want to achieve a behavior similar to Grammarly plug-in, where the underline is only to point out something is wrong with those words, but again, without persisting the underlining.
I found a similar question (word - highlight search results without permanently changing document formatting), but it was asked a few years ago and the solution is not exactly what I'm looking for.
I'm afraid that there is no way to highlight that will automatically disappear if the user saves the document. The answer that you linked to, or this one is the best that can be done in Office.js right now. It is a good idea, however, so please suggest it at Office Developer Suggestion Box.

Office JavaScript API: highlighting text in a document

I'm working on a side project using the Microsoft Office JavaScript APIs. I have been relying on the documentation to find my way around, but I've hit a wall trying to find something in the docs (perhaps it isn't there because it doesn't exist).
Recently I attempting to implement some functionality to highlight some text within a Word document. I don't want to modify the document, mind you; in other words I would rather not use something like ContentControl.insertHtml as that would change the actual content. What I want is to make the text temporarily highlighted (e.g., until the user clicks a "Cancel" button), much like what you see when you perform a search with Ctrl+F (and text matching your search is highlighted in yellow).
Is this possible using the Office JavaScript APIs?
Try getting a reference to the Range object and then setting Range.font.highlightcolor. Have a handler for the Cancel button click event that reverses the color change.
Here is a sample application that uses font.highlightcolor from the Office Javascript API. https://github.com/OfficeDev/Word-Add-in-JS-Redact/

Is there a way in (DocumentFormat.OpenXml.Wordprocessing) to write protect a paragraph?

I understand you can protect the whole document with something like this: myDocument.ExtendedFilePropertiesPart.Properties.DocumentSecurity= new DocumentSecurity("4");
Is there a way to do the same, but to just a single paragraph ?
-thanks in advance
Yes, although I'm on a mobile device and can't check the exact syntax at the moment. But you can find it, yourself.
Start a new document, fairly simple content. In the Word application go to the Developer tab. There's a group/button "Restrict Editing" / "Protect document" (depending on the version of Word). That displays a task pane where you can define the kind of restriction. Select everything BUT the paragraph, then from Step 2 choose "Read-only" (or something like that - not protect for comments or form fields). Make the selection editable for "everyone". In the next step, activate the protection.
Once you have this working, open the document in the Open XML SDK Productivity Tool and you can inspect the underlying Word Open XML syntax. Plus, if you're using the SDK (that's not clear from your question) it will also show you the code for generating the document.

Word forms with too many ActiveX checkboxes load slowly

my company's software product has a feature that allows users to generate forms from Word templates. The program auto fills some fields from the SQL database and the user can fill in other data that they desire. So we have a .dotx template that holds the design of the form, and then the user gets the .docx file to fill out when they call it from our program.
The problem we're having is that some of our users have been finding that the forms take an exceptionally long time to open up and then, once open, are so slow to respond (scroll around, etc) that they're unusable. So in my investigations so far, I've found out that the problem systems are one with lower powered CPUs (unfortunately it happens for systems above our system requirements) and the Word forms that cause the problems are ones with large amount of ActiveX style checkboxes on them. I verified that reducing the ActiveX checkboxes fixes the form loading problems.
So I have the following questions about solutions (we're using Word 2007):
1) Is there any way to configure Word, or some other settings, so that there won't be such a strain opening a Word form with lots of ActiveX checkboxes? Any way of speeding up Word's opening?
2) Using Legacy style checkboxes instead of the ActiveX ones makes the forms load fine, but it looks like the user has to double-click the checkbox and change Default Value->Checked. Is there a way to configure it so that they can simply click on the checkbox to tick it? "Legacy Forms" checkbox as a name kind of worries me (Legacy…), does that mean a future version of word at some point wouldn't load the checkboxes because they're "legacy"?
3) Yes, it became clear to me after a little bit of research into solutions that Word is not the tool for the job for forms like I'm describing. InfoPath seems to be exactly what we should have been using all along but unfortunately I wasn't involved in the decision making or development of these forms, just tasked with coming up with a solution.
I'd appreciate answers to any of these, or if anyone has any other ideas for solutions to this problem.
Thanks
I'm about 3 years too late, but if you want a legacy checkbox to act like a checkbox, you have to restrict editing on the document or section. (You can lock just a section, if you want.) Locking--on Word 2010 it's called "Restrict editing"--is an option under either the Developer tab or the Review tab.
If you restrict editing in this way, the user cannot edit the text but can fill in the form field, so if the form field is a checkbox, the user can click the checkbox on or off; if the form field is a text box, the user can fill the text box.
If you choose to lock off just a section, you'll probably want to use continuous section breaks (Page Layout > Breaks > Continuous) and specify which section. (In the space where you choose form editing as your kind of restriction, there's a small link that lets you specify which section or sections are locked.)