Office-JS Word Add-in Document-to-sidebar communication - ms-word

I'm working on a taskpane add-in for Microsoft Word. So far, I'm able to place comments inside the Docx coming from the sidebar by abusing the OOXML insertion function.
I'm wondering if it's possible to monitor what the end user does with the comment.Is the commented deleted or accepted by the user? It is also significant to monitor the context of the comment - is that changed significantly?
I've considered the following approaches:
Create a ContentControl for the context of the comment to which events can be hooked that check for selection and changes. The downside here is that these ContentControl affect the UI in word and are probably not understood by our end-user. Are there more 'background' ways to do this without affecting the UI too much?
Create an interaction Hyperlink in the comment. I'm not sure if we can 'catch' this as an event or attach a JavaScript hook to this that actually makes it to the add-in?
Poll the document at set intervals to determine if something has happened to the comment or the context of the comment. I'm not sure what the correct hooks for this would be, and how to accurately localize all the changes across the document.
Is there an approach that I missed?
I'm aware that adding these comments is on the roadmap for the office-js, but this has been the case for a couple of years so I'm not sure what the timeframe is for this.
Edit
#Cindy thanks for taking the time to respond! With your help I've been able to get a functioning proof of concept using the hidden Content Control as a prepended OOXML snippet for the comment (So basically approach 1 combined with the OOXML insertion).
I can now capture some of the interaction by adding a binding to the content control and using the EventType.BindingDataChanged, something like this:
Office.context.document.bindings.addFromNamedItemAsync("MyContentControlTest", "text", {}, function (result) {
if (result.status == "succeeded") {
result.value.addHandlerAsync (
Office.EventType.BindingSelectionChanged, function()
{console.log("Don't touch me");}
)
})
})
It still feels a bit circumspect to attach a binding over a ContentControl, but I have not been able to add event listeners directly to the ContentControl. Given a named Content Control (MyContentControlTest) how could I attach an event like the OnDataChanged? And if i read correctly, this last feature is still in Preview, is there a way to find out what the expected release is?

Related

Is there an easy way to search Snippets in SQL Developer?

I find that my collection of snippets has grown far beyond what can be managed by assigning a Category and Name. "I know I wrote this code before, it's probably in one of these three categories but it definitely hit table T and used function F; should my time be spent clicking thru each likely category and dragging out each snippet, reinventing it, or searching the snippets.xml?" is a conversation I have with myself far too often.
I tend to copy the snippet body into the tag so I can hover and see some of what's in there but still, being able to actually search the snippets (like we can do with SQL History) would be amazing. Is there a way?
No, there is no way today.
I'm happy to log an enhancement request on your behalf for that feature.
In the meantime, maybe consider trying the Code Templates instead?
You can 'search' either by the name of your code template, or by the first word of the code template 'source'
type the word, and then ctrl+enter to bring up the list of 'hits'

Intercept a mouse click on a hyperlink in a MS Word document in an OLE container?

I am working with Word in an OLE Container in a Delphi form, although the IDE is largely irrelevant to the question.
Up until now I have been unable to find any way of solving the above question and I have created and maintained my own word processor within my app solely because I have been unable to find a way to intercept hyperlink clicks in Word. Embedded MS Word would be the ideal solution save that Word does not expose an onHyperlinkClick event.
My embedded word processor needs to take over control of the hyperlink click as it is not navigating to a specific url, but triggers the running of a fairly elaborate function, which I cannot/do not wish to try to handle from within Word.
In the absence of an MS Word event, I would guess that the only way of doing this would be via a windows hook. I am not very familiar with hooks and would appreciate any feedback as to whether this is the best way to approach the problem. For it to work I would need the hook to be able to:
Identify the mouse coordinates on screen (that I assume is a given)
Intercept and prevent the mouse click to stop MS Word doing its own thing.
In MS Word I would need an exposed function which translates screen coordinates to the location of objects within the word document. I have looked through the Word VBA reference and couldn't find any immediately obvious function for this, but I have a feeling I have seen reference to such a function previously.
Any feedback as to whether this is a possible and sensible approach would be greatly appreciated.
I have found the answer to the above. It is fairly complex to achieve. It involves both mouse and keyboard hooks.
VBA for Word has a RangeFromPoint function which you can query to find out the the range below the mouse cursor. You then query the range object to get its hyperlinks.
You cannot query the range in the hook procedure as it causes a threads conflict. I added a timer with an interval of 1 millisecond which is enabled in the hook procedure. This makes life difficult if you want to handle the link yourself. I decided to query on mousedown rather than mousemove as latter likely to eat a lot of resource. As such you have to disable the mouse down each time and simulate it outside of the hook procedure if you want it to be handled in the normal way.
There are also all other sorts of problems to be dealt with such as other windows with a higher z order which may be lying over your ole container. You need to check if cursor falls within these windows.
You also need to make sure you don't handle the mousedown where a special key (such as shift) is depressed at the time of the mousedown otherwise you will disable selecting.
Handling opening of the link by pressing the enter key is much easier.
It would all be much easier if Word offered a hyperlinkclick event!

Access 2010 Form: Including example input for fields?

I have an input form in which users submit multiple types of information to the database.
Is there any way I could provide an example input of what should go in each field, upon the form loading?
Some fields I'd expect a small paragraph of text, others are dropdowns. The dropdown fields I wouldn't need to put an example of course, just the string text fields. If I try and include an example in the Default value for example, it would save the default value, which I wouldn't want.
Any help is greatly appreciated - It's worth noting I'm quite new to Access & coding in general.
I agree you probably don't want to use default values, or actually enter dummy data into the actual controls for the reason you mention: saving dummy values to the table.
A few possibilities:
Use a custom tooltip. You can do this by editing a control's "controltip text" property. Keep in mind that tooltips are only visible to the user when they hover the cursor over the specific control.
Add a label below the input control that describes the information that should be put in the control. This would always be visible, but can quickly cause your form to be cluttered and difficult to read.
I should say though, that you want to attempt to make your forms as intuitive as possible. For example, if you expect a paragraph of text, make the textbox much larger than a control only expecting a 6 character string. The more you are concerned with UX (user experience), the greater the chance that users will pick up on expectations using subtle design hints. I highly recommend researching the topic if you are concerned that your users will be unable to decipher the purpose of your form/controls. Be sure to check out the UX page on SE.
Furthermore, you can utilize a control's "AfterUpdate" event to validate the input placed in the control as soon as the user moves away from it. For example, you could test if the input IsNumeric() to validate that numbers were entered instead of text. If text is found, you can use a message box to alert the user, and move the cursor back to the control that is invalid.
Of course, that's the customized approach to just using the control's validation rules. The only issue I have had with the standard validation rules is user exhaustion. It can be irritating for a user to deal with validation messages when they are already aware that a typo was made. With an unbound entry form that requires a save button, I usually batch all control validation into the save procedure. This allows the user free reign to skip controls in the tab order without being blocked by constant validation exceptions.

Content merging AEM

We're looking for a solution on how to best deal with the situation where multiple authors are working on the same page. If the first author pushes in the content, the second should have a way to merge it when he tries to publish. Launches appears to be a way to take care of this but it doesn't seem to be handling content merging. Is there any way an author can view the diff(and or do merge) of the content that might have been pushed by another author while they were working concurrently ?
Please help with any pointers.
Page modifications happen in real time to the underlying structure. They also happen at as small a level as possible.i.e. If you go into a text area and modify the text there, the text node is changed on the server, you aren't saving the entire page.
The only way that person A could interfere with what person B is doing is if they were working on the exact same area of the page. Which, honestly is a process issue. I say this because the answer to your question is that there is nothing out of the box to handle this type of scenario and if you are on 6.0 or higher and looking at the JCR3. JCR3 handles this far worse than the older version did. Last time I checked it didn't support nodes at all
Adding to what Bailey said, AEM OOB allow multiple users to edit same page in real time, though if multiple users are working on same node will be a reason of conflict. Such cases can be managed by defining a process like:
1. Take a lock of page and edit page or
2. Create versions of page and publish versions

SurveyMonkey survey as in-page overlay/modal/lightbox

I've searched the SurveyMonkey website, both help... and developer..., as well as the general net and stackoverflow, and can't find any examples of a SurveyMonkey survey being displayed in an in-page overlay (referred to by some as a "lightbox" or modal).
I think what I need to use is SurveyMonkey's Embed option, as opposed to Invitation or Survey Popups:
http://help.surveymonkey.com/articles/en_US/kb/How-do-I-embed-a-survey-or-have-it-open-in-a-popup-window-on-my-site
I'd like that overlay div to appear, close, etc upon the same triggers as a regular survey would/could, that is open if the user has no previous SurveyMonkey cookie, close when completed or closed by user, etc.
I can probably hack through a solution by forcing the survey into a custom overlay I build, but the behaviors would be more tricky, probably having to read the SurveyMonkey cookie, I suppose. Or, perhaps I could check for certain IDs of SurveyMonkey content that exists at various stages to pull off the behaviors (but I'll have to look at the generated code throughout the process to know if this is an option).
In short, it seems like someone else has surely run into this issue before and likely that a solution has already been created, at least partial to save me some time. I just can't find it.
Here are some things I found on the embed itself:
https://www.surveymonkey.com/blog/en/blog/2013/04/23/how-to-embed-your-survey-on-a-website/
https://www.surveymonkey.com/blog/en/blog/2013/04/16/video-tutorial-how-to-embed-your-survey-on-a-website/
Any and all help much appreciated, pointers/resources, example code, etc. Thanks!