Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[VB JS] Trying to remove characters or pass reference to object to script

New Here ,
Nov 19, 2011 Nov 19, 2011

Hi all

I'm trying to remove characters using VB scripting (well, actually it's via C# and COM but the problem is the same), and I have found out that the Characters class does not have the Remove() method.

What I'm trying to do:

JS:
var tf = indoc.textFrames[0];
var chars = tf.characters.itemByRange(0,10); //just an example
chars.remove();     //not available in vb

So, I'm trying to find out how I could do this in VB?

One very simple way is to iterate through the characters and invoke Delete() on them, but that is highly inefficient.

If there is no other way, is there a way to pass a reference/id of an element from C# environment to a javascript? This way I could have the above code in Javascript and just pass a reference to the textframe/object I would like to invoke the script on.

If I only had the toSource()  method in the vb/COM world I could easily pass the reference, but this is not possible right?

I would need to be able to find the object also if it's deeply nested inside a table of tables and such, so simply using AllPageItems would not work as far as I recall.

Many thanks in advance
Ruvan

TOPICS
Scripting
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 19, 2011 Nov 19, 2011

Hi,

InDesign character object has the delete() method instead of remove() method in javascript.  Both are doing the same task removing.

Else...

You use this trick like which character you want to delete means selecting that characters using vb selection code.

then write the javascript to capturing that selection objects and do whatever you want in javascript.

triggering the js code in vb using doscript method.

Hope this will help you............

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 21, 2011 Nov 21, 2011

Hi Imagine

The delete() method works, but is way too slow.

Unfortunately, using the selection method is not viable because the solution needs to work both on client and server.

If only I could pass a reference to the textframe I want to manipulate (remove) then I could do it in javascript easily. Anybody has an idea on how to pass a reference from c# to the javascript.

Regards,

Ruvan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 23, 2011 Nov 23, 2011

If only I could pass a reference to the textframe I want to manipulate (remove) then I could do it in javascript easily. Anybody has an idea on how to pass a reference from c# to the javascript.

Can't you just call .toSpecifier() on it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 24, 2011 Nov 24, 2011

Hi John

Unless I'm mistaken, the toSource() method is only available from javascript - not vb/com/c#.

Best regards,

Ruvan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 24, 2011 Nov 24, 2011

I certainly don't know, but I said Specifier not Source.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 24, 2011 Nov 24, 2011
LATEST

Sorry, my bad. I forgot to type that I tried both. That method does not exist either

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines