What is the format of a Word hyperlink that uses a Range?

D

Dave Jenkins

I want to create a hyperlink in an Excel cell that goes to a specific
location in a Word document. But I don't want to change the document by
inserting a bookmark or anything else. I will use VSTO 2005 SE to capture the
location in Word and create the hyperlink in Excel.

I can do exactly what I want manually in Word 2007 and Excel 2007 using
drag-and-drop. If I drag and drop the selected text from Word to Excel, using
the right mouse button, and choose the "Create hyperlink here" option, the
cell will have a hyperlink that does exactly what I want.

But I can't figure out the format of the hyperlink. An example hyperlink is
"c:\example.doc# 1,12204,12210,94,,Note 1". Is this format documented
anywhere? I know the 12204 and 12210 parameters are a Range.Start and a
Range.End. The "Note 1" parameter is the text I selected. But what are the
rest of the parameters? Thanks for any help.
 
C

Cindy M.

Hi Dave,

Mmmm. When I try right-click, drag-and-drop the "Create Hyperlink here" option
isn't available... No idea what technology this might be, but "94" is probably
the number of characters in that range.
I want to create a hyperlink in an Excel cell that goes to a specific
location in a Word document. But I don't want to change the document by
inserting a bookmark or anything else. I will use VSTO 2005 SE to capture the
location in Word and create the hyperlink in Excel.

I can do exactly what I want manually in Word 2007 and Excel 2007 using
drag-and-drop. If I drag and drop the selected text from Word to Excel, using
the right mouse button, and choose the "Create hyperlink here" option, the
cell will have a hyperlink that does exactly what I want.

But I can't figure out the format of the hyperlink. An example hyperlink is
"c:\example.doc# 1,12204,12210,94,,Note 1". Is this format documented
anywhere? I know the 12204 and 12210 parameters are a Range.Start and a
Range.End. The "Note 1" parameter is the text I selected. But what are the
rest of the parameters? Thanks for any help.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
D

Dave Jenkins

Hi Cindy,
I did some experimenting and the "Create Hyperlink here" option only appears
on a saved document. If you create a new document and drag-and-drop before
you save it, the option is grayed out as you described.

I don't think the 94 is the text length because my selected text was "Note
1". Also, the difference between the Range.Start and Range.End (which I know
are 12204 and 12210) is only 6 characters.

It seems to me that Microsoft should document this hyperlink format. Since
it's contained in an Excel spreadsheet, they will always have to support it
for backward compatibility reasons. And it's very convenient to have a way to
link to any location in a Word document without changing that document. You
just need software to find the Range.Start and Range.End numbers. A VSTO
Word add-in can easily do that.

Anyway, I would really like to know what the other parameters in the
hyperlink represent. It would save me from doing some guesswork and
experimenting. Thanks.
 
D

Dave Jenkins

I am still looking for an answer on this question. I did figure out the
following hyperlink parameters by experimenting:
(1) there is a tab character following the #, (2) the first parameter is 1
for the document body, 2 for a header or footer, 3 for a footnote, 6 for an
endnote, and 7 for a comment. Are these numbers from some enumeration? (3)
The second and third parameters (12204 and 12210 in this example) are the
Range.Start and Range.End of the text that I selected. (4) The fourth
parameter is a WdBuiltinStyle enumeration. You have to add 1 and negate it.
In this example, 94 represents wdStyleHtmlNormal. (5) The fifth prarmeter is
a mystery. (6) The last parameter is the actual text that I selected. It
truncates to a maximum of 32 characters in length.
 
D

dansyoz

Dave Jenkins wrote on 03/29/2007 11:24 ET :
I am still looking for an answer on this question. I did figure out the
following hyperlink parameters by experimenting:
(1) there is a tab character following the #, (2) the first parameter is 1
for the document body, 2 for a header or footer, 3 for a footnote, 6 for an
endnote, and 7 for a comment. Are these numbers from some enumeration? (3)
The second and third parameters (12204 and 12210 in this example) are the
Range.Start and Range.End of the text that I selected. (4) The fourth
parameter is a WdBuiltinStyle enumeration. You have to add 1 and negate it.
In this example, 94 represents wdStyleHtmlNormal. (5) The fifth prarmeter is
a mystery. (6) The last parameter is the actual text that I selected. It
truncates to a maximum of 32 characters in length.
Did anyone find more detail on this?
I have found that in Word 2007 inserting via VBA a hyperlink format of say
{HYPERLINK "file:///C:\\Users\Username\\filename.doc" \s "1,7047,7054,0,,"
works.
I found the \s switch (which appears to be undocumented) via inspecting
manually created Paste-As-Hyperlink result.
The start and end offsets (7047 and 7054 respectively) seem to be relative to
document element.
 
D

dansyoz

Dave Jenkins wrote on 03/02/2007 17:54 ET :
I want to create a hyperlink in an Excel cell that goes to a specific
location in a Word document. But I don't want to change the document by
inserting a bookmark or anything else. I will use VSTO 2005 SE to captur the
location in Word and create the hyperlink in Excel.

I can do exactly what I want manually in Word 2007 and Excel 2007 using
drag-and-drop. If I drag and drop the selected text from Word to Excel using
the right mouse button, and choose the "Create hyperlink here"
option, the
cell will have a hyperlink that does exactly what I want.

But I can't figure out the format of the hyperlink. An example hyperlink is
"c:example.doc# 1,12204,12210,94,,Note 1". Is this format
documented
anywhere? I know the 12204 and 12210 parameters are a Range.Start and a
Range.End. The "Note 1" parameter is the text I selected. But what
are the
rest of the parameters? Thanks for any help.
This appears to correlate to the "internal use" attribute arblocation (ref Wor
XML schema).
Refer - http://msdn.microsoft.com/en-us/library/aa172760(office.11).aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top