Replacing the occurrences of a Word by links
Hello
I'm writing a Javascript script that should replace all occurrences of a word given in an Indesign CS3 document by a hyperlink pointing to a given URL.
I am very new to Indesign scripting, and I don't know where to start. I tried searching this forum, but couldn't find the answer to my problem.
If anyone can help...
Thank you
Bertrand
You can use my findAndDo Script (the blog is in German): http://www.indesignblog.com/?p=7
for a hyperlink, you need to change:
app.changeGrepPreferences = NothingEnum.nothing; app.findGrepPreferences = NothingEnum.nothing; app.findGrepPreferences.findWhat = "SEARCH"; var erg = app.activeDocument.findGrep (); for (var i = erg.length - 1; i >= 0; i--) { var _hlinkSource = app.activeDocument.hyperlinkTextSources.add(erg[i]); var _destination = app.activeDocument.hyperlinkURLDestinations.add("http://www.google.de"); app.activeDocument.hyperlinks.add(_hlinkSource, _destination); }
Tags: InDesign
Similar Questions
-
I have the documents in Dropbox I share with others. Most of the time it works. However, when trying to share a single file for a particular email the original WORD document appears on my screen (until I pressed SEND) in PDF format. When the person receives the invitation of Dropbox and press the link in his Inbox, WORD file appears also in PDF format. There should be no PDF anywhere in this transaction.
Dropbox has a feature of practice to preview the DOC files to PDF in Firefox built-in PDF Viewer. It is convenient, but can lead to this problem that you eventually download the document in PDF format instead of a DOC file.
As long as the recipient is using the download button on Dropbox toolbar above the Viewer (see screenshot attached comparison), the beneficiary must obtain the original instead of the preview format.
What is the question?
(See also the current thread: firefox is reading from word to pdf files when I download from DropBox.com)
-
Add the signature field to the second occurrence of two words (nieme Word) on the page
I have a script that searches for two words ("APP ENG") on a page and adds a digital signature field.The trick is that there are two occurrences of these words and place the script in the field of digital signature on the first ocurrance of the two words.
I need the digital signature script to add to the second occurrence of these two words.There was a counter added the script, but this place then the field on the word ("ENG"), it might have to do with the meter to count one word instead of two.
If someone can help me to modify the script to count the words and the occurrences of two words instead of one word it would be most appreciated.Script as follows:
var ckWords; pair of words to testvar number = 0;
numWords = this.getPageNumWords (0); number of words on the page
loop through the words on the page
for (var j = 0; j < numWords-1; j ++) {}
get the pair of words to test
ckWords = this.getPageNthWord (0, j) + ' ' + this.getPageNthWord (0, j + 1); test words
If (ckWords == "ENG APP") {}
Count += 1;
If (count == 2) {}
var q = this.getPageNthWordQuads (0, j);
convert quads in the rotation by default user space
Userspace used by links
m = (new Matrix2D).fromRotated(this,0);
mInv = m.invert)
r = mInv.transform (q)
r = r.ToString)
r = r.split(",");
var m = this.addField ("EngSignature", "signature", 0,
([r [0], [1] r, r [2], r [5]]) ;
}
}
}
Thank you.
You must use the left coordinates of the first table and the right of the second table.
-
Count occurrences of matched words
All,
Does anyone know the syntax or the algorithm to count the occurrences of matched words that separate compared cases of two tables or columns? Here is a simple example of the type of comparison, I would like to perform. I found the regexp_count function, but it only works in 11g. Unfortunately, I have Oracle 10 g. Any help would be greatly appreciated. Thank you
i.e.
drop table compare_matched_words;
create table compare_matched_words)
number of query_id,
query_string1 varchar2 (80).
query_string2 varchar2 (80)
);
insert into compare_matched_words values (1, 'oracle' 255', oracle1 255');
insert into compare_matched_words values (2, ' larry ellison or ','larry or ');
insert into compare_matched_words values (3, 'oracle and text', 'and');
insert into compare_matched_words values (4, ' groups1 market share ","market share");
insert into compare_matched_words values (5, ' larry or "," larry ellison ");
insert into compare_matched_words values (6, 'oracle1' 255', oracle 255');Is not in 11g. Before that you can solve the task, you need to split QUERY_STRING1 and QUERY_STRING2 in words and then compare the words for QUERY_ID even. To split the string into words use something like:
select query_id, regexp_substr(query_string1,'\w+',1,column_value) query_string1_word from compare_matched_words t, table( cast( multiset( select level from dual connect by level <= length(regexp_replace(regexp_replace(QUERY_STRING1,'\w+','A'),'[^A]')) ) as sys.OdciNumberList ) ) / SQL> / QUERY_ID QUERY_STRING1_WORD ------------------- ------------------- 1 oracle 1 255 2 larry 2 or 2 ellison 3 oracle 3 and 3 text 4 market1 4 share 5 larry QUERY_ID QUERY_STRING1_WORD ------------------- ------------------- 5 or 6 oracle1 6 255 14 rows selected. SQL>
Now:
select t1.query_id, t1.query_string1, t2.query_string2, count(*) matchin_word_count from ( select query_id, query_string1, regexp_substr(query_string1,'\w+',1,column_value) query_string1_word from compare_matched_words t, table( cast( multiset( select level from dual connect by level <= length(regexp_replace(regexp_replace(query_string1,'\w+','A'),'[^A]')) ) as sys.OdciNumberList ) ) ) t1, ( select query_id, query_string2, regexp_substr(query_string2,'\w+',1,column_value) query_string2_word from compare_matched_words t, table( cast( multiset( select level from dual connect by level <= length(regexp_replace(regexp_replace(query_string2,'\w+','A'),'[^A]')) ) as sys.OdciNumberList ) ) ) t2 where t2.query_id = t1.query_id and t2.query_string2_word = t1.query_string1_word group by t1.query_id, t1.query_string1, t2.query_string2 order by t1.query_id / QUERY_ID QUERY_STRING1 QUERY_STRING2 MATCHIN_WORD_COUNT ------------------- ------------------------------ ------------------------------ ------------------- 1 oracle 255 oracle1 255 1 2 larry or ellison larry or 2 3 oracle and text and 1 4 market1 share market share 1 5 larry or larry or ellison 2 6 oracle1 255 oracle 255 1 6 rows selected. SQL>
SY.
-
Replace the last occurrence of a word in a string
Hello
I need to replace the last occurrence of a word in the string. Example of form:
"I like fruits and vegetables as" need to replace the last occurrence of 'like' that is just before the vegetables and not 'as' before the fruit.
Something like that!
SELECT REGEXP_REPLACE('I like fruits and also like vegetables','like','hate',1,2) data_col FROM dual;
-
Find the occurrence of the word in a list separated by commas
Hello
I need to find the first occurrence of a word in a list separated by commas.
Example list:
Now I'm looking for the word: bambimonster,daemon,shark,bambi,sky
Result should be the first calculation of the event: 4
Now I'm looking for the word: Monster
Result should be the first calculation of the event: 1
Hope you can help.
TobiasHi, Tobias,.
This can be more efficient, because it does not use CONNECT BY or regular expressions. Instead of splitting the string to the level of every comma, just find the target string and count how many commas occur in front of her.
WITH got_found_pos AS ( SELECT list_txt , INSTR ( ',' || list_txt || ',' , ',bambi,' ) AS found_pos FROM table_x ) SELECT list_txt , found_pos + 1 - LENGTH ( REPLACE ( SUBSTR (list_txt, 1, found_pos) , ',' ) ) AS item_num , found_pos FROM got_found_pos WHERE found_pos > 0 ;
Delimited lsits storage is usually a bad idea in a relational database. It is best to store each item in the list on a separate line.
-
by clicking on link in windows mail open the Web page in Word
Problems with links in Windows Mail
When I click on a link in an e-mail message in windows mail, Microsoft office opens and the Web page in Word. Any ideas how can I fix?
Hi traymos,
· Remember to make changes to the computer, after which the issue started?
I suggest you to make sure that Internet Explorer is configured as web browser by default. Take a look at the following links:
Change the programs that Windows uses by default
by clicking on the http links in windows mail will open word instead of the browser
I hope this helps.
-
When you combine files to PDF a single file has been replaced by another, can the program automatically replace files? in other words, I has not been chosen, and it has been merged in the document.
Sorry, I don't have any ideas. This isn't a usual problem. It may be useful to repeat carefully to see if it happens again and check that the files contain what you expect.
-
Link to find out how to replace the battery in the clock on laptop Compaq Presario 1247
Once upon a time, I had a link to a guide who offered guidance on how to access the motherboard in order to replace the battery in the clock on an old laptop Compaq Presario 1247. Can anyone provide this link?
Hello
This should be the Guide of maintenance & Service you're looking for.
Kind regards
DP - K
-
Find and replace all occurrences of a string within the current paragraph.
I did so much work, and it's my last method to implement.
I want to get the current active doc the current paragraph and replace all occurrences of a string inside this paragraph with another string.
For example, say I have the following paragraph in a document:
«This is a sentence that.» This is another sentence. It is also another sentence. The sentence ".
If the user opens the document containing the paragraph and goes to this paragraph by clicking in any place in there, I want to replace e.g.g "another punishment" with "phrase.
But only in the current active paragraph in the active document.
I found a code with F_ApiFind and F_ApiGetTextRange to get the current text selection, but I can't think of a way to do it.
Post edited by: Efstathios Chatzikyriakidis
Problem solved people. Thank you.
-
How to replace the spaces before and after a Word with tabs using GREP or search - replace
Here's the scenario:
I have a paragraph with spaces (can be 1 or more) at the beginning (before the first word) and a single space after the first word (is be a number if this matter - which may be a single digit or more).
I'm looking to replace the spaces before each paragraph with a single tab and replace one tab so of space after the first word (number). In addition, I would like to apply a paragraph style to it.
Thank you very much in advance for anyone who can find a solution. It sounds like a solution of some sort GREP but can't nail. Thank you.
^(\s+)(\S+)(\s+)
and replace with \t$2\t and define the change of setting fit your style.
-
How can I add a style "BOLD" grep on the first occurrence of a Word?
Hi all
I need help on adding a style "BOLD" grep on the first occurrence of a Word.
I can add the "BOLD" to the word, but it adds to all occurrences, see below:
GREP style (Incorrect)
Apply Style: "BOLD"
Text: \ < Lorem Ipsum\ >
Nam Lorem Ipsum semper pellentesque tincidunt. UT nisi sit amet arcu nulla tristique dictum. SED commodo total non mauris cursus pretium. Lorem Ipsum Aliquam erat volutpat. Morbi id pretium justo. Nam lorem quis facilisis molestie risus fermentum. Vestibule ut sem elit. Nunc eget neque Sed elementum augue EU outbound.
I need only the "BOLD" to add to the first occurrence of the word, as below:
Nam Lorem Ipsum semper pellentesque tincidunt. UT nisi sit amet arcu nulla tristique dictum. SED commodo total non mauris cursus pretium. Lorem Ipsum Aliquam erat volutpat. Morbi id pretium justo. Nam lorem quis facilisis molestie risus fermentum. Vestibule ut sem elit. Nunc eget neque Sed elementum augue EU outbound.
Thanks in advance for the help!
This should do it for you
Apply style
"BOLD"
text (? i) ^(.+?) Lorem Ipsum
apply the stye
Book
text: ^. * ? (? = Lorem Ipsum)
The first expression search all the text from the beginning of the parapgrah through the Lorem Ipsum
The other defines the rest of the text before the Lorem Ipsum to the base style (book, novel, or whatever your basic style)
-
Regex to replace all occurrences of an empty string, except the last
Hello, everyone!
I need get to a regular expression to replace all occurrences of an empty string except the last. Right now I'm doing this with this code:
As you can see, to do this, I have to make two calls: one for replaceAll and another for replaceFirst to get rid of the last character. So I would like to get rid of the call to replaceFirst and have the variable of regex as being a regular expression that would be to insert the character along the chain of all but the last. I'm really not very good with regexs, so I ask your help here. The thing I work, but I think it would be more elegant with just a regex to do.public static void main(String[] args) { String str = "abc"; String regex = ""; System.out.println(str.replaceAll(regex, "-").replaceFirst("-$", "")); // -a-b-c }
Thank you in advance.
MarcosTry this:
String data = "abc"; System.out.println(data.replaceAll(".", "-$0"));
-
Find the first occurrence of a Word
I have a script which detects and counts all occurrences of a Word.
I need the script to find the FIRST occurrence of a Word only.
Can any advise please how do I change the script to find the first occurrence of the word?
Script as follows:
{
numWords = this.getPageNumWords var (0);
for (var i = 0; i < numWords; i ++)
{
var ckWord = this.getPageNthWord(0,i);
If (ckWord is 'MATERIAL')
{
/ * Script going here based on the finds the first occurrence of the word 'MATTER ' * /.
}
}
}
I tried var CKWord = this.getPageNthWord (0,0); but reports from the rear console is UNDEFINED?
numWords = this.getPageNumWords var (0);
var number = 0;
for (var i = 0; i)
var ckWord = this.getPageNthWord(0,i);
If (ckWord == "ISSUED") {}
Count ++;
If (count == 2) {}
var = this.mouseX Coord.var annot = this.addAnnot({)
page: 0.
type: "Stamp."
name: "AppStamp."
Rect: [coord + 1000, 2300, 30, 2820]
rotation: 90,.
({AP: '#C94cHAFFa42U1gTH5Tug5C'});
break;
/ * this.flattenPages (); */
}
}
} -
Replace the baggage files and maintain links
Hello-
I need to replace a file of baggage in my current RH7, with a new version of doc project. How to maintain links to the document so that I don't have to change the properties of binding in each project file? Or if not possible, how to identify which documents are currently related to this baggage file so I can edit hyperlinks? Thank you!
Hello
For my money, I think that a more secure approach would be to always use the same file name for the file of baggage. Just make the difference in the level of the source.
For example, call the RedRabbit baggage file if you want, but on your hard drive (or anywhere where you store the file), you have RedRabbit Version One. Simply copy and rename so that you can easily replace the baggage file. In this way, you don't have to play muddy muck with Binder and search and replace and all that rot.
See you soon... Rick
Useful and practical links
Wish to RoboHelp form/Bug report form
Begin to learn RoboHelp HTML 7 or 8 days - $24.95!
Maybe you are looking for
-
Phone calls to the Microsoft call centre.
Hello I'm sick to death of receiving your call center phone calls telling me there is a problem with my computer, when this 'thing' has yet been turned on and still less currently in use . Also sick of these people not understand English and even les
-
I have a Dell dimension running XP and IE8 will not respond
I have a Dell Dimension 4500 XP pro and IE8 will not respond.When I click it it flashes up on top of the screen and disappears. To this effect, I can't watch the updates from Microsoft. Any ideas, anyone please? Delete.
-
connection initialization failed
G62
-
Is it possible to embed the map search option in the app
Hello. I am trying to add looking for a card for a location in my application. Its similar user can search full address as 100, Street Bay, Toronto and it will show the geo-information from the same place. Thank you.
-
How tweak you to adjust noise reduction in lightroom for mobile?
Currently, it provides only low/medium/high, but a minimum of 25 is VERY aggressive. I find that I rarely need anything beyond 10 to 25 or the images gets too much "trouble". Why not just provide the same volume as in the desktop version (like almost