A Thursday challenge - does anyone have any good ideas for this scenario in the intranet migration (CMS2002 - SP2007) project I'm working on:

I need to identify documents on the intranet which have embedded links to pages. I can identify links to other documents (since in CMS2002, such links are in the format '/NR/rdonlyres'), but pages are more tricky as I think the only thing to pattern match on would be the extension (.aspx, .htm etc.). Remember however, that the links could be in format "Policy Document", meaning the link target itself isn't in the document content as seen by say, a search engine.

Some other challenges:

  • The documents are in CMS 2002 and it would NOT be easy to write CMS code for this task. For one thing, the original source code for this solution is missing presumed dead (and there is no documentation), so building a fully-functional working VM is unlikely. I have a restored SQL db though.
  • Docs are Office 2003 format

I have some ideas, but all are a time-sink compared to how much time we actually have. I love to hear about any site-scraping tools which might help here, but all suggestions welcome.

  • So you are trying to build of list of Office 2003 documents (doc, xls, ... where does it stop?), and this list is basically a sub set of the current set of documents that stored in a CMS2002 site, and the criteria for each of these documents is that it must contain at least one hyperlink to a web page (any web page, or only those under a specific domain e.g. the domain of the CMS2002 site?). Is this correct? Commented Feb 25, 2010 at 13:52
  • Yes, that's about it. Ideally to cover all Office docs, though the client believes the links are only in Word docs. We're only interested in links to the CMS site. I probably wasn't clear, but the reason for identifying these documents is so that links can be updated (i.e. fixed) after the migration. We're really looking just for a report - fixing can be done manually by the content authors. I can think of some solutions which don't involve fixing the links in the Office docs, but obviously we'd prefer to fix at source. As well as know exactly how many of these we've got. Commented Feb 25, 2010 at 14:49

2 Answers 2


Don't know anything of the structure of CMS 2002 database (are the docs stored as BLOB like in sharepoint?), but the parsing of the documents themselves should be easy enough.

If you open a word 2003 document in notepad you can see the hyperlinks as they are prefixed by HYPERLINK even if they are displaying text instead of the URL.

You parse each document as a string and list out those which contain embedded links to the intranet. I don't know if you could swop out the link text and save the document back without breaking it, but you could generate a report at least.

  • That's good information, thanks. This means I can actually write some quick and dirty code to see how many of these we've got. So this solves one half of the problem at least. Commented Feb 26, 2010 at 9:49

Presuming you already found a way to iterate all your documents, you could load the document in C# using Microsoft.Office.Interop

for example for word use Microsoft.Office.Interop.Word.Application, open the document, iterate Hyperlinks collection.

This article shows how to open documents (this is where you wish you were using C# 4 and optional arguments:-):

  • Thanks Anders. I think this approach is more technically correct, but I prefer it less since it involves reading/research etc. Since this task is like item 374 on the migration task list (:)), that's unlikely to happen to be honest, so unless it takes hours to run I'll likely go with generic parsing code per the other suggestion. Both these approaches probably fit into my "time-sink" category though :) I take it no-one is aware of a tool which may help? Commented Feb 26, 2010 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.