Setting Links in Word Programmatically

Since I didn’t find anything on this topic via Google…


Just a quick “how to” on setting links in Microsoft Word programmatically (in this case, C#):


The code is wrapped in a function call I’m using for testing. The key part of this is detecting the currently selected text and using the ApplicationClass.Selection and then invoking _Add. The method takes three parameters. Make sure that your first parameter is a Range class instance, your second parameter is passed by reference, and your third parameter (the SubAddress) is set to System.Reflection.Missing.Value.

This should set the text point to any input URL.

You may also like...