anybody help me plss??
1.- Add a hyperlink a object in InDesign CS2
select the object (textframe. image), right click > interactive > New Hyperlink
2.-in visual studio (vb)
I try...
For Each ObjTxtFrame In IdDoc.TextFrames
'how to determine when an object has a hyperlink??
Next
And
For Each objHyperlink In IdDocActual.Hyperlinks
MsgBox(objHyperlink.id) ' OK
Next
I want to know the id of the object that has the hyperlink
ayuda por favor
http://jongware.mit.edu/idcs6js/pc_HyperlinkPageItemSource.html -- check its sourcePageItem.
I don't do VB but to "get the id of the object that has the hyperlink" this works in Javascript:
objHyperLinks = app.activeDocument.hyperlinks;
for (i=0; i<objHyperLinks.length; i++)
if (objHyperLinks[i].source instanceof HyperlinkPageItemSource)
alert (objHyperLinks[i].source.sourcePageItem.id);
(which, very helpfully, tells me that "227" is its id. Why do you need just the id? There are very few circumstances where it's useful (actually, see below for one, although it can be rewritten without using 'id' at all).)
The trick here is that the source property of a hyperlink points to the link properties of the item that's hyperlinked, through a second property sourcePageItem. The source type can be one of several: Cross Reference (which I haven't used yet), HyperlinkTextSource (a regular hyperlink in a text), and HyperlinkPageItemSource, which can be any valid page item. It's the latter you are interested in, so it seems, so that's what it checks for.
The inverse -- given an object and finding what it links to -- is one of the more tricky operations. An object does not define a 'hyperlink'; you need to check its id against the entire list of links.
This Javascript, when run with a page item selected, will show the URL if it is a hyperlink to an URL, or will end silently when it is not.
Again, it uses the Javascript-only construction 'instanceof', and I cannot recall if there is a similar command for VB.
objSelection = app.selection[0];
objHyperLinks = app.activeDocument.hyperlinks;
for (i=0; i<objHyperLinks.length; i++)
{
if (objHyperLinks[i].source instanceof HyperlinkPageItemSource)
{
if (objHyperLinks[i].source.sourcePageItem.id == objSelection.id)
{
alert (objHyperLinks[i].source.sourcePageItem.id+" = "+objHyperLinks[i].destination.destinationURL);
break;
}
}
}
North America
Europe, Middle East and Africa
Asia Pacific