Change the word.

Hello

I want to have the last word (cursor left Word) in the text framework would change to another word.

<-textFrame

STEP 1: run the script.

STEP 2: It selects the last Word by the cursor.

STEP 3: Download the selected word.

STEP 4: Type the word I want to change.

STEP 5: Change the word.

======================================================

#targetengine session;
main();
main() function
{
var curDoc = app.activeDocument;
mySel var = app.selection [0];

If (!) App.Selection [0])
Alert ("did not select the object.");

Else if (app.selection [0] .textFrames)
{
if(App.Selection[0].) Happy) / / Word blocks
var mySelWord = mySel.words.lastItem (.silence);

on the other
var mySelWord = "have not selected the word.";
}


var l is new window ('pallet', 'Form');.
w.Add ('statictext', undefined, ' get the selected word: ");
getText var = w.add ('edittext', undefined, ' ');
getText.text = mySelWord;

w.Add ('statictext', undefined, ' change the word: ");
var changeText = w.add ('edittext', undefined, ' ');

getText.characters = 20;
changeText.characters = 20;
changeText.active = true;
var myButtonGroup = w.add ("group");
myButtonGroup.alignment = 'right ';
BT1 var = myButtonGroup.add ('button', undefined, 'Change the word');
BT2 var = myButtonGroup.add ('button', undefined, 'Cancel');

BT1.onclick = function()
{
myDocument var = app.activeDocument;

app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
Set the search options.
app.findChangeTextOptions.caseSensitive = false;
app.findChangeTextOptions.includeFootnotes = false;
app.findChangeTextOptions.includeHiddenLayers = false;
app.findChangeTextOptions.includeLockedLayersForFind = false;
app.findChangeTextOptions.includeLockedStoriesForFind = false;
app.findChangeTextOptions.includeMasterPages = false;
app.findChangeTextOptions.wholeWord = false;
Search in the document for the string "copy" and change it to "text".
app.findTextPreferences.findWhat = getText.text;
app.changeTextPreferences.changeTo = changeText.text;
myDocument.changeText ();
Clear the find/change text preferences after the search.
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;

w.Close ();
}

w.Show ();

}

=============================================

I can get the word, if run the script after the text selection (block).

But I don't know how to get the last word without selection (block).

Please help me.

Even a little helps a lot.

Thank you.

Hello

Your code is struggling while veryfying selection.

I suggest to create a new function to do this work and back on a Word or false.

This function must check if:

  • selection is valid
  • selection is "text".
  • detect if the selection is 'block' or 'cursor '.
  • find the last word and back OR false

That is like this:

var mySelWord = lastWord() ? lastWord().contents : "did not select the word.";
function lastWord()
{
  if (!app.documents.length || !app.selection.length)
  return false;
  var
       resWord = false,
       mSel = app.selection[0],
       mCursor, cIdx, mStory;

  if (mSel.hasOwnProperty ("baseline") )
       mCursor = mSel.insertionPoints[-1];
  else return resWord;

  cIdx = mCursor.index;
  mStory = mCursor.parent;

  do {
       if (!cIdx) break;
       if (mCursor.words.length) {
            resWord = mCursor.words[0];
            break;
       }
       mCursor = mStory.insertionPoints[cIdx--];
       } while (true)

  return resWord;
  }

Use var mySelWord of another script task

Jarek

Tags: InDesign

Similar Questions

  • Is it possible to change the wording of the acknowledgement of receipt

    In order to make the status of an email I received more clear, I need to change the wording of the acknowledgement that sends Firefox. Is there a way to do this?

    Short answer 'NO '.

  • How to prevent the spell checker to automatically change the word I type?

    Hello

    I own a MacBook Pro, OS X Yosemite 10.10.5.

    Processor: Intel Core i5 at 2.8 GHz
    Memory: 8 GB 1600 MHz DDR3

    I was struggling with the spelling corrector assuming what I type is wrong and so it changes the word for another while I am always type, the result is that the mess this creates a bad word that will not be corrected because the editor already "fixed" it while "I screwed up".

    The fact is that I'm Brazilian, so my first language is Brazilian Portuguese, which uses a series of special characters such as to, a, a, a, e, e, i, o, o, o and c, Furthermore, we seem to have many more words in our vocabulary and verb time if compared to English. The corrector seems to get confused with that too, and some Word's closer to her I am writing.
    What seems to be the boss, is that in English, the feature is very useful, but when I type special characters, it assumes that this word should not be even with the input source for Brazilian Portuguese, which makes me wonder why I would fix it for my language if I have not noticed any difference at all. He gets it wrong in 90% of the time and a Word by a word it is delay my work and make me hate my computer.

    Please, don't you know any solution for this? Go to system preferences > keyboard > text and UN-checking the "correct spelling automatically" doesn't change anything, even after restarting the computer. It's stressing me out of having to correct this as the corrector mess every 5 minutes!

    Any ideas how to get rid of it?

    Thank you!

    kodimoto wrote:

    even with the input source for Brazilian Portuguese

    The input source has nothing to do with spell checking and AutoCorrect.  Dictionary used for this defined under Edition > spelling and grammar > show spelling and grammar (or in the system preferences, keyboard, text, spelling).  For best results, use the dictionary for your language and not "automatic".

  • I downloaded an attachment in Notepad and you want to change the word. How can I do this?

    I downloaded an attachment in Notepad and you want to change the word.  How can I do this?

    Right click on the saved file.
    Select: Open with on the shortcut menu.
    Click: Choose [default] program.
    Select: Word.
    Check: Always use the selected program to open this type of file.
    Click OK.
     
  • Social sharing - that I can change the wording of "read more"?

    Is it possible to change the wording of "read more"? See screen capture below. If so, how can I change?

    IMG_1926.PNG

    It is not possible to change the text "read more" at the moment. Under the roadmap, we evaluate several areas of customization, including the ability to change/customize the user interface text.

    Kristy

  • How can I change the words in pdf format

    can someone help me, I want to change the words I pdf

    Hello

    You must have the full Acrobat application rather than just drive.

    PDF Editor, edit the text in PDF files. Adobe Acrobat DC

  • How to change the word "HOME" on the tab to the name of the site?

    Hello

    I was wondering if there was an easy way to change the word "HOME" on the tab to the name of the site? the bit next to the favorite icon?  Any help is greatly appreciated

    In outline, it is enough to double-click the label beneath the thumbnail of the homepage and rename.  If you use an auto-menu of Muse, which renames all the links too.  This may or may not be what you want to accomplish.

    Another option is to open your page (s) Master, go to Page > Page Properties > metadata and enter your text to the title of the Page title prefix.  This text will appear in the tab before the page for each page name to that Master Page is applied.  This is a good option if, for example, you want your name or business name appear on each tab.

    Or, open a Page-master, go to Page > Page Properties > Options and use the name of the Page and the title of the Page.  Try it to see how they behave.

    John

  • I converted a PDF file to word.  Can I change the words, but not the page.  I can't change the margins. If I delete a picture of the page, space where the image is unusable.

    I converted a PDF file to word. Can I change the words, but not the page. I can't change the margins. If I delete a picture of the page, space where the image is unusable.  Can someone help me please? Gary

    Thank you, Gary!

    I appreciate your comments! Start with the basics: Getting Started with ExportPDF

    And here's a more complete step by step (that you already know, but I'll give the full game!):

    1. Sign in to your account on https://cloud.acrobat.com/exportpdf.
    2. Click on PDF files select export.
    3. Click on choose the files on my computer.
    4. Select one or more files and click on choose (you can select multiple files by pressing the Shift or Ctrl key when you click on the file).
    5. To convert to the: menu popup, select the output format you want (in this case, Microsoft Word).
    6. Let the language of the local menu Document configured to English (unless the PDF is in a foreign language).
    7. Click Export to Word. (The name of this button will vary depending on what format you selected in step 5)
    8. Once the file is converted, it will appear at the bottom of the window, listed under exported files.
    9. Hover your mouse over the thumbnail image of the file, and then click the icon that appears on the left side of the thumbnail to download the file in your downloads folder. (You can also click on the files tab in the upper part of the window to see a complete list of all converted files).
    10. Once you have downloaded the file, you can open it up in Word for editing.

    I hope this helps! If this isn't the case, you know where to find me!

    Best,

    Sara

  • is it possible to change the word to the document microsoft word pad

    Is there a way to change a word pad to document microsoft word document

    Yes. However, methods available depend on what program you have installed.

    For example

    If Word is installed: open the document in Word Pad and save to RTF. Open the document saved in Word and re - save in Word format.

    Tom Ferguson

  • How can I change the words in the spell checker?

    I've saved an incorrect word in my spell checker in Windows Mail and now can't change it. I tried to change my English version, but it seems that all of my custom entires are moving to the new version. Any suggestions would be helpful.
    Thank you!

    How do I change a word in the custom dictionary for the Spell Checker in Windows Mail
    http://www.Vistax64.com/tutorials/82062-Windows-Mail-spell-checker-dictionary.html

    Bruce Hagen MS - MVP [Mail]

  • Change the word 'from' when paging

    Hello

    is it possible and how to replace the word "* of * ' with a translation, which is displayed when the paging, when you use the paging Type: line varies X to Y of Z.

    TIA

    Yes you can change it. They are built in Messages and what you need to do is provide the built in the name of the message, then the appropriate translation.

    for example

    Globalization, application to translate, translate Messages

    Message name: WWV_RENDER_REPORT3. X_Y_OF_Z
    Fila (Spanish translation) (s) %0 - %1 %2

    There is a list of integrated messages that can be translated in the Documentation of the APEX on globalization.

  • Pages to change the word "modulo" when writing BUG

    Hello to everyone, I'm having this problΦme during work on the pages, when I'm writing and start typing the word "modulo" pages automatically replaces the word exactly once I typed "mo" and press the "d" pages replaces the word by 'mad '.

    I download a video to see the clear error.

    https://youtu.be/NqKE4s8DE6E

    Thanks for your help.

    Hi Jose,.

    I use Pages ' 09, but instructions for 3 Pages may be similar.

    Go to the Pages menu, click Preferences, and then choose AutoCorrect.

    Uncheck «Automatically use suggestions from the spell checker»

    Type the word.

    If she does not get "corrected", right-click (Ctrl-click) on the word and select learn from the menu that appears.

    Kind regards

    Barry

  • How to change the word spelling dictionary?

    Whenever I click on the spelling dictionary and the dictionary does not recognize a Word, and I'll add it to the dictionary, but there is no way to erase this word.

    Whenever I click on the spelling dictionary and the dictionary does not recognize a Word, and I'll add it to the dictionary, but there is no way to erase this word.

    You don't say what word processing software you use. You say "Word spelling dictionary", but with the 'word' PAP, you can refer to the spelling of the words, rather than the Word program.

    But if you talk about Microsoft Word, please post in the appropriate forum. Not only is your off-topic message here in a forum of Windows, but if you ask in the right place, you'll have a much better chance of getting the answer you need, since this is where technology experts of your drag.

  • How can I change the words when I scan on my computer, I do alms Church lost paper.i and now I want to digitize the book to my windows xp, its words

    I give alms Church lost paper.i and now I want to digitize the book to my windows xp, its words

    I give alms Church lost paper.i and now I want to digitize the book to my windows xp, its words

    When you scan a document, what you get is a * photo * of the words, not the words themselves. If the quality of this image is good, you can convert editable text using a software called OCR (OCR) character type.

    Unless you already have an OCR program (many scanners come with a 'Lite version' of some OCR program) you will need to buy. The best one is generally regarded as spnord Fine Reader, but Omnipage (which I use) is also very good.

  • [REQUEST] Change the Word Developer

    Hi friends! does anyone know how to change the provider Portal password? I tried clicking and browsing the link I could find but did not find the link for password change

    Thank you

    developers!

    in the case where someone facing the same problem, you can change your bbid by https://blackberryid.blackberry.com/bbid/login/ has soon!

Maybe you are looking for