a really ugly workaround is the following.
Suppose myIdApp is a reference to the InDesign application.
Suppose we want to relink the third link in the active document.
Then we could write:
However, this doesn't work, as you already noted.
Instead we can write:
Dim myResult as Variant
Note the following Points.
I tried using a VB file object obtained from FileSystemObject.GetFile() as an argument in the VB call Links(3).Relink().
But this didn't work.
I tried various other things, but this is the only one that worked for me.
Hope that helps.
I'm having the same problem when relinking. I'm using the following environment:
1. InDesign CS5 Server
And I tried with the following code:
string script = "app.documents.links.item(1).relink(new File(" + "\"C:\\Temp\\Test.jpg\"))";
But when I run the application it gives me the following error:
System.Runtime.InteropServices.COMException (0x00007306): Either the file does not exist, you do not have permission, or the file may be in use by another application
But I've checked that the file exists and no one is using the file.
I'm in trouble with this, any help will be highly appreciated.
Finally my problem is fixed :-)
It was the problem in my script. Now I've written the script this way and worked.
string script = @"app.documents.item(0).links.item(1).relink(new File(""C:\\Temp\\Test.jpg""))";
Since I stumbled on this thread with the same error, here's my fix.
InDesign is looking for a URI (file://c/temp/test.jpg")
So, instead of:
you could do:
(or any other way you prefer to use the Uri objects)
Thanks for sharing, I'll try it first thing next year! Just curious: how did you find this out? Is it documented somewhere?
There wasn't much to find in the quick google search I used. The help files I refer (I use a downloaded copy of Jongware's HTML files http://jongware.mit.edu/idcs5js/) just mention String. The error message "Cannot create the link resource from the given URI." in hindsight was a pretty big hint that I should send it a URI.