index > Visual Studio Tools for Office > Track a bookmark onscreen with a custom winforms control?

Track a bookmark onscreen with a custom winforms control?


I'm using VSTO 2005 to create a Word 2003 customization that stores complex annotations against bookmarks that the user has placed throughout the document. The users have asked if I can float a graphic or control on the document next to their bookmarks, similar to the UI bubbles that appear in Word 2003 when you track changes (e.g., deleting with tracked changes removes the text and draws a pointer to a bubble on the right margin which reads: "deleted: <delete text>").

I've created many custom controls before, and I'm no stranger to ownerdraw and the graphics objects--I just don't know how or if I can float a user control on the Word document at run time. Even if I can, are there are enough events to be able to pin it to a given text range's position while the user scrolls up and down or adds/removes text from the document? I know this is asking a lot, but any pointers at all to get me started will be greatly appreciated.

Thanks in advance!

Jesse

JesseJ

I don't think you can get enough control of the Word interface for exactly what you have in mind. Word doesn't provide many events, it tends to lock out many of the Windows API commands, and the graphics interface is... "touchy". (To see what I mean by this last, open Word, display the Controls Toolbox (UserForms ActiveX controls) and put one in the document. Now drag the scrollbar and watch the how the control does NOT move with the scrolling - only once you release the scrollbar does it reposition.)

Some ideas for alternatives:

Use the COMMENTS functionality. If it's expected the users will work with this, you should be able to use a special "identifier" so that your comments are obvious. I think (not something I've ever tried) you could even write to the document's XML to enter your program as an "editor", with a set of initials, which would give your comments a different color from other users'.

See if you can coerce the SmartTags functionality to recognize your bookmarks. The little dots aren't as "obvious" as the balloons, but "something is better than nothing".

Use an ActiveX control (as the Controls Toolbox example, above). You can wrap a managed code control into a COM ActiveX, or just use the controls (a label, perhaps) that come with Word. ActiveX controls - like most graphic objects in Word - have two positioning "modes": Inline with text or "floating". Since you want a "pointer" to the text, you'd probably want to put the control into a Drawing CALLOUT. In any case, a real danger would be that the user would be able to drag these things and delete them. The only way to stop this would be to apply some kind of document protection - but that would preclude the users being able to perform some actions.




-- Cindy Meister (Word MVP)
Cindy Meister
Comments might be a simple and decent alternative. I'll play around with that a little. I've already had to rule out smart tags after trying a few different experiments for this project. Also, I was wondering if people would be able to delete/move embedded activex controls...argh. Does Word 2007 offer any hope of making this sort of thing easier? Thanks for the ideas!
JesseJ

About the only thing I'm aware of are the Content Controls, but beyond the "title" that appears when you click in one, I don't know of anything.

There was a request in this group (that was seconded) a few weeks ago for a way to make content controls always visible. It's been submitted as a suggestion, but certainly won't be implemented in this version of Office. I presented a couple of "workarounds" to make the controls visible, using standard formatting. Perhaps that could be of some help.

I suppose you could "highlight" annotations to make them standout (and remove the highlight/shading when printing). Possibly use a Document Actions pane to provide context (annotation) related information (instead of balloons); trigger it to the WindowSelectionChange event.

RE the ActiveX: as I mentioned in my last reply, unless you activate some form of document protection, the user will definitely be able to mess up that stuff.




-- Cindy Meister (Word MVP)
Cindy Meister

JesseJ --

Nothing new to add to this thread, but wanted to chime in here and say we've desired functionality similar to this for a while.

We want the ability to callout specific portions of a document using non-printable formatting (like the highlighting used by comments, the red/green squigglies used by the spelling/grammar check, etc). Then, when the user mouses over this called out text, we want to recieve that event so we can do stuff (like display a balloon tip, update the actions pane, etc).

Simple use case:

* User highlights some text and clicks a button in the actions pane. (for example, in your case the selected text could be an annotation)

* System programmatically creates bookmark marking this text and then applies some sort of customizable formatting to callout the text. This formatting could be background highlighting, squigglies, dotted underline (like smart tags), border around text (like content controls), etc. Essentially any formatting to visually callout the text to the user that (1) is visually appealing, (2) will not interfere with the styling/formatting of the document, and (3) will not be printed. [content controls are a great example of this]

* When user mouses over the bookmark/formatting, system will receive an event and display a balloon tip with some detail information.

We've trying to reproduce the above using a variety of methods (comments, smart tags, winform controls "on" the document, etc) with little success. None of the solutions we've found work very well and are not very elegant. Currently, we using standard Word highlighting to callout text. This works okay b/c it doesn't mess with the document's formatting, but it's not a great solution (very limited selection of highlight colors, many highlight colors are dark in color, no mouseover events are exposed, nested highlighting doesn't work, our programmatic highlighting can be blasted by the user's manual highlighting, etc).

We would love to see this kind of support in future versions of Word/VSTO. If you come up w/ any cool ideas in the meantime, let us know.

Thanks!




ThirtySix Software - http://www.thirtysix.net
ThirtySix Software
reply 5

You can use google to search for other answers

 

More Articles

Switching to an existing instance of outlook and opening the cale...
How to uninstall an outlook add-in?
Customizing Outlook programatically
Filling data islands on servers
PLEASE READ FIRST: Non-VSTO Question/Issue Resources
Getting reference of an excel cell from other sheet
Unable to Show/Hide NamedRange object from the ActionPane
auto_close addin unload
Implement similar behavior as http:// address for Network File Pa...
VSTO 2005 for Outlook links
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

Trouble installing VSTO with Word 2007 B…
add text to anywhere in MS word document
How to Associate Custom Data with XMLNod…
performances problem
How to Develop a Com Addin that works fo…
Deploying user defined chart in client m…
Why no RefEdit control in VSTO?
B2TR and VSTO v3?
XMLNode instances in Word Document
Setting the AppDomain ApplicationName
Pivot table using c#
HELP: On MSDN, Office 2003 Key Un-Known?
Release object
Caption on custom ActionPane
Security Deployment Package

Hot Articles

Null values displayed as 0 in OWC Pivot …
Outlook 2003 VSTO error
Can't Run Sample
Help - releasing WinWord instance at end…
VSTO 2005 Beta2 FAQ
VSTO 2005 SE Beta documentation
Please Help this Amateur r.e. Office 97!
Deploying Excel Smart Doc Solution to Wi…
Help need with Infopath 2003 toolkit for…
Help embedding Excel documents into a Wo…
Make smart tag recognizer stop recognizi…
Retrieve worksheet from range and call w…
Toolbar button on all mail items in Outl…
ClickOnce Compatibility With VSTO Add-ins
Pivot table using c#

Recommend Articles

Visual Basic 2005 and MSWord Rule Bar
User Define Function, Action Pane and Wo…
Some wrong in Excel with the option Dele…
VSTO Serious Deployment Problem. NamedRa…
importing data from an excel file
Trying to save an excel file. c++
Clear data from excelsheet
Protected sheet gives exception with Dat…
Server-side VSTO scalability and licensing
Outlook 2003 navigation bar
The default behavior to click and open a…
vba excel compiling / creating library
Deleting a line break
If I download Visualt Studio 2005 standa…
regard excel very urgent