Archive

Posts Tagged ‘vsto’

CrossRef++ (A Microsoft Word Add-in)

March 11th, 2011 Angus Macdonald 3 comments

This is a Word 2010 that replaces Word’s in-built ‘add cross-reference’ tool. Why? — because it has annoyed me greatly whilst writing my thesis!

Installer (EXE Version).

Source code as ZIP, on Github.

Please note that this only works in Word 2010, not on any earlier versions.

Why this is ‘needed’

The standard word tool (pictured below) quickly becomes tedious to use in large documents for a number of reasons:

  • You have to switch between references for things (like figures and numbered items) constantly, and you have to use a drop-down box to do this.
  • It doesn’t remember your last referenced item, so if you’re constantly referencing a figure that is two pages down the list, you constantly have to scroll down to that reference.
  • It doesn’t remember the size of your reference box, so even if you have a massive monitor, you can only ever use a tiny fraction of it to search for references.

The Standard Word Cross-reference Tool

What CrossRef++ Does Differently

  • References are displayed in a task pane, which typically stretches the length of a screen, but can be moved around as well.
  • It remembers (roughly) where your last used reference was for each type (figure, numbered item, etc.), so you don’t have to scroll as much as before.
  • It provides a few big buttons to at the top to change reference type, which makes it quicker to change.

The CrossRef++ Tool

What it Doesn’t Yet Do

  • It doesn’t support all types of references (for endnotes and other things you need to use the old tool).
  • It doesn’t handle re-sizing the task pane well.
  • It doesn’t allow you to search through references, though I’d like to do that eventually.
Categories: Side Projects Tags: , ,

Word 2010 Add-in: Word Frequency Counter

November 27th, 2008 Angus Macdonald 38 comments

I created this add-in to count the occurrences of each word in a given Word 2007/2010 document and then either display the result within Word, or save it to a CSV file. Both the executable and the source are available below.

Word Frequency Counter EXE (for Word 2010)

Word Frequency Counter EXE (for Word 2007) – Without Ignore List

Word Frequency Counter SRC (for Word 2010)

(These files seem to be a lot larger because of some additional dependencies that have been created. If you don’t care about the ignore list feature, the old files are listed at the bottom of this post.)

For the Technically Minded

The add-in is written in C# using Visual Studio 2008. Among the things I find interesting about the solution are:

  • The use of LINQ to sort the dictionary (a hashmap) which stores the words (key) and count (value) by value, rather than using an complicated comparable code. I discovered this here, and was suitably impressed.
  • The use of BackgroundWorker to multi-thread the computation of the results, and to relay the progress of this computation back to the interface. This example is fairly good.

The add-in also does the following things (in case, like me, you’re struggling to find how to do something in VSTO):

  • Retrieves all the words (tokens, more specifically) in a given word document and loops through them
  • Creates and populates a custom task pane
  • Adds some buttons to the Office 2007 ribbon in the review tab
  • Saves a string to a file, with the location specified by the use

Hopefully this helps you in some form!

Update (25/09/2010): Updated for Word 2010 with an ignore list feature added.

Update (17/11/10): Someone at online-tech-tips has written a good overview of the add-in here.

Update (20/11/2010): Updated with a basic in-built set of ignored characters including bullet points, dashes, and quotes. Also the ability to ignore numbers.

Update (27/03/11): Another write-up of the add-in here.

Categories: Side Projects, Work Tags: , , , ,