I’d really appreciate thoughts on how one might approach the following:
I’m editing a medical textbook (written in Microsoft Word) that has a lot of cross references to other points in the text of the form “See [section title]” that need to be converted to “See [section title] at [index]” where [index] is something like “C5S9.1” (referring to Chapter 5 Section 9.1). I can generate a dictionary/lookup table of [index] and [section title] pairs fairly straightforwardly e.g. as a CSV file. It’s just how best to approach the RegEx search-lookup-replace I’m unsure about. I have Keyboard Maestro if this helps. This will be a one-time process so speed isn’t that much of a concern (it will undoubtedly be quicker than doing it manually!)
Setting aside that Word is not the best tool for writing complex texts, there is a question to go with this.
Cross referencing is Word often uses hyperlinks to headings or part of heading (e.g. for numbered headings) bookmarks. Do you have and need to retain these for producing a hyperlinked electronic version such as a PDF; or are you really just replacing plain text that someone has manually maintained (which would be odd because Word can do that for you).
Since you are using Keyboard Maestro, it is safe to assume that you are on a Mac, and so have access to AppleScript. That might be a good starting point for you if you have familiarity with AppleScript. However, I think VBA still offers the most powerful way to “get your hands dirty” with Word and, I don’t know for sure, but might be the only practical way to automate the updates if you do need the hyperlinking described above.
As always, there is the option to do it manually, and this might be something you could farm out as a more menial task, Mechanical Turk style.
Thanks for this response Stephen. Yes I’m on a Mac and have occasionally dabbled with AppleScript but this would be a next level challenge for me!
Fully understand the “wouldn’t have started from here” sentiment about the decision to use Word but that’s stipulated by the publisher (or at least I have to submit the finished manuscript as a word doc and there’s a lot of custom styles etc that would be lost if I exported to RTF or plain text that would need to be reapplied). That said the references don’t need to be links: in fact the publisher stipulates just text (they don’t like us to use Word’s cross referencing features). I’m basically providing sign posts for the copy editor who will be producing both page proofs for a physical book and an eBook version. The details of that workflow aren’t known to me — I just know I need to provide the text signposts.
Any pointers would be very much appreciated. I hadn’t thought about AppleScript as I’d unthinkingly assumed Word isn’t very scriptable
[quote=“RobForsyth, post:1, topic:15650”]
I’m editing a medical textbook (written in Microsoft Word) that has a lot of cross references to other points in the text of the form “See [section title]” that need to be converted to “See [section title] at [index]” where [index] is something like “C5S9.1” (referring to Chapter 5 Section 9.1).[/quote]
Two thoughts, given it’s a big job and extremely sensitive to any errors:
Use Word for Windows. That is the “gold standard” for .doc/.docx editors.
Figure out how to create these indexes using Words built-in index features if it’s at all possible, so that those references dynamically track the indexed locations.
In an ideal process the document would’ve been set up correctly and authored using the appropriate document features. Failing that, you want to minimize opportunities for any errors to creep in as it passes through editing and revision processes. Rolling your own ad-hoc scripts to apply non-live changes to the text is one of those risks. Live indexes will track correctly any order or numbering changes; static text cannot.
Honestly, for a task like this which is both specialized and common, I think you should ask for advice on a professional Word/DTP forum, with people who are skilled with building and maintaining TOCs and indexes using the standard tools for the job. This will be a solved problem somewhere. Much better chance of getting the best advice, rather than amateur inventiveness that creates a rod for your own back.
Thanks — I can certainly see the wisdom in your comments however I’m constrained by publisher’s workflow and for whatever reason they ask us not to use Word’s dynamic indexing and cross-referencing features (which I’m reasonably familiar with) so I may have to resort to Stephen’s manual/Mechanical Turk approaches. I appreciate your taking the time to respond.