How do I obtain the method / enumeration for ChangeLinks RRS feed

  • Question

  • I recently had a problem using the ChangeLink method which was answered by Tom Xu.  This post can be found at

    However, in Tom's resolution of the issue he instructed me to use a particular format that gets handed to ChangeLink, and the first part of that is to send a string representing the document/file such as "Word.Document.12" or "PowerPoint.Show.12" or this kind of string.  The problem is, that is fine, by how do I determine that string?  I asked this as a follow-on question, but I think Tom missed that and though is answer works pretty well, I am now in the conundrum of trying to figure out how I identify a wide variety (both products and versions) of Office Documents.

    I have searched for information on some method to determine this as each document comes in, but I cant find anything - and I cannot be guessing at it because this often makes ChangeLink fail.  I checked FileInfo and FileVersionInfo, but these do not return this information...

    So, simply put, how do I determine this string?  Sure, I know a bit from the filetail coming in (e.g., DOC vs DOCX) but that is not enough since multiple versions of Office use DOC and of course Office 2007 and 2010 both use DOCX, etc.

    How do I get this enumeration / method to obtain the proper string for Word, Excel, Access and PowerPoint?


    Monday, March 14, 2011 1:11 PM


  • For the benefit of anyone who is looking for this information on using the ChangeLinks method with an OLE link...

    First and foremost, Microsoft's own documentation must be either wrong, or partially wrong.  You can find their description of the ChangeLinks method at this link:

    but as you can see in the above posts, available at this link...

    Tom Xu is advising me that ChangeLinks works a bit differently.  I have found this to be true at least when you are using it against OLE links.  Tom says:

    In the ChangeLink method you aren’t able to use the string which comes from open file dialog’s FileName property immediately. For example, If you want change to a Word file you need to use “Word.Document.12|'[your Word file path]'!''”(If you only want change the link to .docx, use it!) as you NewFile variable, if you want to change to a PowerPoint file you need to use “PowerPoint.Show.12|'[your PowerPoint file path]'!''”.

    My follow-up question to Tom was, ok, but how do I obtain the proper string (e.g., "Word.Document.12")?  This question, as well as the same question I asked again in another post, was never answered so I had to try to figure it out on my own, and the only way I could see to get these strings was to call the Registry. 

    Note - I am not sure this is exactly what the method requires, but the code below does work - however, since it is not documented and Microsoft's own documentation is wrong (and misleading) I am 'best-guessing', but sharing it none the less.

    Seems the trick is to call the Registry with the FileTail in question (or in this case, querying for the default Registry value) and that will return the string needed to make ChangeLinks actually work properly.  The code I use to call for this string is:

        Private Function GetRegFileType(ByVal FileTail As String) As String
            Dim RegKey As RegistryKey                  
            Dim RegBaseKey As RegistryKey         
            RegKey = Registry.ClassesRoot
            RegBaseKey = RegKey.OpenSubKey(FileTail, False)
            If RegBaseKey Is Nothing Then
                Return ""
            End If
            Dim DefValue As String
            DefValue = RegBaseKey.GetValue(Nothing, "", RegistryValueOptions.None)
            Return DefValue
        End Function

    In this case I am calling with the given filetail I need translated (say for example .DOCX) and use the Registry GetValue method BUT BE SURE TO HAND IT 'NOTHING' AS THE DEFAULT and this will then return the string "Word.Document.12" which can then be used as Tom advised to make ChangeLinks function properly with an OLE Link.

    I hope this helps someone else and if anyone can refine what I have discovered and am merely presuming is correct, it would be nice if they posted any further information in this thread.


    • Marked as answer by B_E_L Tuesday, March 15, 2011 12:19 PM
    Tuesday, March 15, 2011 12:19 PM