Word Add in VSTO - How to get multiple ranges of text copied on multi-select - ms-word

I am trying to store and high-light text copied by user when he opens the word file back. When he copies one paragraph, I am able to highlight (I am storing all this copied information for e.g. range values in an XML file) but when he copies content of multiple paragraphs using Ctrl Button, I am unable to get individual range values.
Could you guys help on this?

What you are trying to do is not supported by (the current versions of) Word because programmatic access to discontiguous selection is limited. In particular, you cannot access the different ranges in that selection (you can only the last subrange).
The limitations are listed in detail in this MSDN article:
Limited programmatic access to Word discontiguous selections

Related

The auto numbering/bullets of the Source MS Word document do not automatically align with those of the Destination MS Word document

It happens when a user inserts a Word Document(Source) into another Word Document(Destination) - auto numbering/bullets didn't work...
I wont to insert text here, and continue auto-numbering of source as it in destination:
Step 1
But it inserting above without auto-numbering:
Step 2
I have an answer from MS that it's a feature of MS Word :(.
So, the question is - is it possible to automatically align the above either by use Word Automation ( via C# , .NET Interop Word APIs )?
I mean to align the source document contents as per the destination document’s Auto-numbering. The same is about Bullets...
Please help - we are open to any suggestions/ recommendations.
Both documents need to have the same style definitions for both the Paragraph Style of the text being copied and also the List Style that organizes the numbering or bullets. Using automation, you can copy styles between the files before actually moving the numbered or bulleted text.
I agree with John.
The basic idea is to use the Define New MultiLevel List Dialog to define a new multilevel list in which each level you would be using is attached to an existing paragraph style. A paragraph style can be attached to only one level in one list. Then use the styles to apply the numbering.
Once you have them set up, you apply the numbering by using the styles, not the numbering controls.
Setting up the numbering linked to styles can seem a bit convoluted. Step-by-step instructions for doing it in Windows can be found here:
http://www.shaunakelly.com/word/numbering/numbering20072010.html
Backup: http://web.archive.org/web/20130510174814/http://www.shaunakelly.com/word/numbering/numbering20072010.html
For a Mac, John has a page showing the Mac controls to accomplish it.
http://www.brandwares.com/bestpractices/2016/06/outline-numbering-in-word-for-os-x/
Backup link: http://web.archive.org/web/20200912134758/http://www.brandwares.com/bestpractices/2016/06/outline-numbering-in-word-for-os-x/
These describe the only known ways to have consistent numbering in Word in heavily-edited / co-authored documents.

Is there an Emacs read-only or view mode that allows inserting some text?

Here's the use case: I'm writing a novel in Emacs (in org-mode). One part of my writing/editing flow is to read over some large portion of what I've written, collecting notes/possible edits/etc as I go. The sort of thing you'd do, on paper, by printing it all out and then writing notes in the margin.
I want to prevent myself from, as I do this kind of review, actually doing any writing -- but that's surprisingly hard. Like, if the buffer is editable, I start to type a brief note about a fix, then find myself starting to restructure / fix a sentence, and next thing I know, I've spent five minute polishing
a single paragraph. This not only slows me down, it breaks my ability to imagine a reader's response.
I've tried just putting the buffer in view-mode, and that sort of works -- but then it's laborious to try to identify the places I want to go back and review/fix up.
My ideal would be, to have something in view-mode, which I genuinely can't edit, but which, as I move the cursor through it, I could hit some key combination, and it would allow me to enter a brief note in the minibuffer, which would then get inserted into the main buffer, at point, possibly inside brackets or a comment or some such.
Does anyone know of something like that? Or have any pointers to something similar which I could try to adapt?
You can easily set bookmarks at any locations. And bookmarks can contain annotations.
If you use library Bookmark+:
The annotations are in Org Mode by default, and they can even be separate files (by default they are part of the bookmarks themselves, so stored in your bookmarks file).
You can bookmark not just a position but also a region of text, whether a sentence, paragraph, page, or an arbitrary span of text.
You can automatically name bookmarks as you set them, if you don't care about the names.
Updated after OP's comment saying "I prefer to shove the comments/questions/notes directly into the text of the novel. Because I end up adding/deleting/moving text a ton, and I want the notes to move with the text":
Bookmarks move with the surrounding text. That is, they generally get relocated automatically, since the surrounding text is recorded as part of the bookmark, and when jumping to a bookmark that text is looked for.
Occasionally the context has changed so much that a bookmark can't be relocated automatically, and you are prompted to relocate it manually.
But yes, bookmarks are stored in a bookmark file, separately from the files they target. There are both advantages and disadvantages to this feature. Advantages include (1) removing clutter from the text (annotations, including notes about possible text changes are metadata), (2) immediate access to particular text locations from anywhere, (3) a separate, persistent record/history of work or thoughts on it, (4) you can have multiple, separate sets of bookmarks/annotations for the same target text.
One thing you might find handy, when using bookmarks especially for annotating a particular file: C-x p C-l switches to a bookmark file that has only bookmarks for the current file or buffer, creating such a file on the fly if none
exists. (This is available only with Bookmark+.)

emacs package for working with tagged regions?

I'd like to be able to apply tags to regions of code and text and to be able to use these to narrow visibility to navigate - ideally across multiple files. So for example if I was researching C16th European history I could tag insert and and zoom around around cromwellish stuff quickly, limit my searches to cromwellish regions, etc. It's important that tags pairs shouldn't have to be "well-formed" because I might want to start an region inside of a but end first. And, obviously, I'd to be able to list all my tags, and to search or narrow on combinations of them.
I can't find anything like this. Org-mode comes closest, but its tags are headline based, which makes stopping one tag while continuing other painful - plus I need headlines as headlines, and I'd like to be able to tag code this way too.
Is there anything like this? Or any toolkit that would be a good start to write this?
Library Bookmark+ provides what you are asking for, I think. It enhances standard Emacs bookmarking in several ways, including some that respond to your request.
You can bookmark locations of all sorts, and the recorded bookmark information can include the region limits/context. (If the region is active when you set the bookmark then the region info is recorded.)
When you jump to the bookmark, the region is re-activated (if the region was recorded).
If the content of the destination file (or whatever) has been modified since the bookmark was last updated, so that the text around the recorded region has changed, the bookmark and region are automatically relocated (assuming that the new destination and limits are recognizable and thus locatable).
Bookmark+ also lets you tag any bookmark (or file), in multiple ways. Tags are arbitrary, free-form strings (but you can also optionally associate arbitrary Lisp values with them.)
And you can list all tags, search and narrow on tag combinations (unions, intersections, etc.). Tags are one of the most important Bookmark+ features.
Library Icicles provides additional enhancements regarding the use of Bookmark+ bookmarks and tags.

Is there a way to detect when a field mark with 'can grow' has truncated the field data?

I do not normally work with crystal, but I have spent nearly 2 days looking for a way to do this.
The problem is that I have a number of lines of text that need to show on a report, but need to cut off after 8 lines and show a 'more' prompt to inform the user that they need to go look at the rest of the details online. This was originally handled by storing the data as individual lines already wrap to size and counting the lines with a formula and conditionally showing a separate 'more' field. They have since added the ability to use html to the text, but this made the current way of doing things wrap incorrectly and show the html mark up.
I wrote a database function to combine the text into a single field and use the HTML text interpretation to display it correctly on 7 other reports that do not limit the text length, and the max line count works great for limiting the text size, I just can't figure out how to show the 'more' prompt when needed.
Any suggestions would be greatly appreciated.
GrumpyGeek,
If your database function now combines the text into a single field does this mean the original way, with the separated lines, is still stored? If so, why not add another calculated field called 'line-count' that tallies the old line-based data?
So you'd still have your new combined HTML field and this new field that you could use to show the 'more' button when 'line-count > x'?
Alternatively, another option might work, but would be a bit touchy. That is to make the formula that shows the more button trigger when the field length exceeds x. The catch is that html mark-up isn't displayed, and heavy use of it would skew the amount of text required before you should show the 'more' button. Put another way, a field with very heavy use of mark-up ( and tags) might force the 'more' button earlier than it should. Unless you could somehow make either your 'line-count' calculated field exclude the mark-up OR make the length calculation do the same.
This would be possible if MSSQL or Crystal Reports could run regex to strip the mark-up.
If NONE of the above works, the only other thing I can suggest is to look into UDFs. Crystal allows you to load an external library that you write. These will read functions you write and show them in the function list inside Crystal. If you do this, then you could easily write a routine that strips the HTML and calculates when the more button should be shown.
Good luck with it.
Ideally, there would be a property of the DB field that would return its displayed line count. Unfortunately, there is no such property.
You could try counting the # of line ending characters (e.g. carriage return, line feed). If they are > 7 then show the hyperlink. In a HTML situation, you have to count ending elements (e.g. ). You could make use of a RegEx UFL to make it easier to identify the elements.
Probably the easiest route is to the DB to calculate the # of lines and return that as another field. Use this field to hide/show the hyperlink.

Is there a way to show all docvariables from a word file?

I have a Microsoft-Word File which contains several DocVariables.
In our application we fill/replace these DocVariables with content.
With the shortcut Alt+F9 I can switch in a mode in which I can see the DocVariable.
But in the document I have now, there are DocVariable which I cannot see.
Is there a way/mode in Word 2007 in which I can see all the DocVariables which are defined in the Word-File?
As far as I know there is not a way to do this with MS Word's built in features. You could write a custom VBA script that would get a list of all the DocVariables. But even easier than that I use the following program when I need to do what you are saying: http://gregmaxey.mvps.org/word_tip_pages/cc_var_bm_doc_prop_tools_addin.html
It is a free add-in for Word that has done the job very well the times I used it.