Get the error not defined for the current document in the script

I get a "error number: 2" "error string: myDoc is not defined" in my script.

I modified a few scripts so that they cross my entire book and open each section (document) in my book, and run the code for each section.ext

The code runs great and opens and closes the sections where it does not add links to text, but once, it opens a document and view text that you CAN add links, it generates this error.  Here is my code:

main();
exit();

function main() {
    var myBook = app.activeBook,
            myDocs = myBook.bookContents.everyItem().getElements(),
            myDoc,
            myHyperlinkStyle,
            myCount = 0;

    for (var i=0; i< myDocs.length; i++) {
        myDoc = app.open(File("\\\\computerOnNetwork\\c$\\Folder\\" + myDocs[i].name));
        myHyperlinkStyle = myDoc.characterStyles.item("linkstyle");

        try {
            var script = app.activeScript;
        } catch(err) {
            var script = File(err.fileName);
        }
        var myScriptFolderPath = script.path;
        var myFindChangeFile = new File(myScriptFolderPath + "/SearchTextAndUrls.txt"); //mac path for users desktop //File.openDialog("Choose the file containing the tab separated list"); 
        //alert(myFindChangeFile)
        myFindChangeFile = File(myFindChangeFile);
        var myResult = myFindChangeFile.open("r", undefined, undefined);
        if(myResult == true){
            app.findTextPreferences = NothingEnum.nothing;
            app.changeTextPreferences = NothingEnum.nothing;
            //Loop through the find/change operations.
            do {
                //read 1 line into myLine
                myLine = myFindChangeFile.readln();
                myFindChangeArray = myLine.split("\t");

                //The first field in the line is the value to find 
                myFindVal = myFindChangeArray[0];

                // second is the url
                myFindUrl = myFindChangeArray[1];

                doSearchAndReplace(myFindVal, myFindUrl, app.activeDocument);

            } while(myFindChangeFile.eof == false);
                myFindChangeFile.close();
                // reset search
                app.findTextPreferences = NothingEnum.nothing;
                app.changeTextPreferences = NothingEnum.nothing;
        }
        alert("Done! " + myCount + " hyperlinks have been added.");

        myDoc.close();
    }
}

function doSearchAndReplace(stringfind, urlstring, searchin) {
    app.findTextPreferences.findWhat = stringfind;

    //Set the find 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;

    var myFoundItems = searchin.findText();

    for (i = 0; i < myFoundItems.length; i++) {
        var myHyperlinkDestination = myMakeURLHyperlinkDestination(urlstring);
        myMakeHyperlink(myFoundItems[i], myHyperlinkDestination);
        myFoundItems[i].applyCharacterStyle(myHyperlinkStyle, false);
        myCount++
    }
}

function myMakeHyperlink(myFoundItem, myHyperlinkDestination){
    try {
        var myHyperlinkTextSource = myDoc.hyperlinkTextSources.add(myFoundItem);
        var myHyperlink = myDoc.hyperlinks.add(myHyperlinkTextSource, myHyperlinkDestination);
        myHyperlink.visible = false;
    }
    catch(myError){
    }
}

function myMakeURLHyperlinkDestination(myURL){
    //If the hyperlink destination already exists, use it;
    //if it doesn't, then create it.
    try{
        var myHyperlinkDestination = myDoc.hyperlinkURLDestinations.item(myURL);
        myHyperlinkDestination.name;
    }
    catch(myError){
        myHyperlinkDestination = myDoc.hyperlinkURLDestinations.add(myURL);
    }
    myHyperlinkDestination.name = myURL;

    //Set other hyperlink properties here, if necessary.
    return myHyperlinkDestination;
}

Any help is greatly appreciated!

That ends up being my fixed/final code:

main();
exit();

function main() {
    var myBook = app.activeBook,
            myDocs = myBook.bookContents.everyItem().getElements(),
            myDoc,
            myHyperlinkStyle;

    for (var i=0; i< myDocs.length; i++) {
        myDoc = app.open(File("\\\\computerOnNetwork\\c$\\Folder\\" + myDocs[i].name));
        myHyperlinkStyle = myDoc.characterStyles.item("linkstyle");

        try {
            var script = app.activeScript;
        } catch(err) {
            var script = File(err.fileName);
        }
        var myScriptFolderPath = script.path;
        var myFindChangeFile = new File(myScriptFolderPath + "/SearchTextAndUrls.txt"); //mac path for users desktop //File.openDialog("Choose the file containing the tab separated list");
        //alert(myFindChangeFile)
        myFindChangeFile = File(myFindChangeFile);
        var myResult = myFindChangeFile.open("r", undefined, undefined);
        if(myResult == true){
            app.findTextPreferences = NothingEnum.nothing;
            app.changeTextPreferences = NothingEnum.nothing;
            //Loop through the find/change operations.
            do {
                //read 1 line into myLine
                myLine = myFindChangeFile.readln();
                myFindChangeArray = myLine.split("\t");

                //The first field in the line is the value to find
                myFindVal = myFindChangeArray[0];

                // second is the url
                myFindUrl = myFindChangeArray[1];

                doSearchAndReplace(myFindVal, myFindUrl, app.activeDocument, myDoc, myHyperlinkStyle);

            } while(myFindChangeFile.eof == false);
                myFindChangeFile.close();
                // reset search
                app.findTextPreferences = NothingEnum.nothing;
                app.changeTextPreferences = NothingEnum.nothing;
        }
        alert("Done! Hyperlinks have been added.");

        myDoc.close();
    }
}

function doSearchAndReplace(stringfind, urlstring, searchin, myDoc, myHyperlinkStyle) {
    app.findTextPreferences.findWhat = stringfind;

    //Set the find 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;

    var myFoundItems = searchin.findText();

    for (i = 0; i < myFoundItems.length; i++) {
        var myHyperlinkDestination = myMakeURLHyperlinkDestination(urlstring, myDoc);
        myMakeHyperlink(myFoundItems[i], myHyperlinkDestination, myDoc);
        myFoundItems[i].applyCharacterStyle(myHyperlinkStyle, false);
    }
}

function myMakeHyperlink(myFoundItem, myHyperlinkDestination, myDoc){
    try {
        var myHyperlinkTextSource = myDoc.hyperlinkTextSources.add(myFoundItem);
        var myHyperlink = myDoc.hyperlinks.add(myHyperlinkTextSource, myHyperlinkDestination);
        myHyperlink.visible = false;
    }
    catch(myError){
    }
}

function myMakeURLHyperlinkDestination(myURL, myDoc){
    //If the hyperlink destination already exists, use it;
    //if it doesn't, then create it.
    try{
        var myHyperlinkDestination = myDoc.hyperlinkURLDestinations.item(myURL);
        myHyperlinkDestination.name;
    }
    catch(myError){
        myHyperlinkDestination = myDoc.hyperlinkURLDestinations.add(myURL);
    }
    myHyperlinkDestination.name = myURL;

    //Set other hyperlink properties here, if necessary.
    return myHyperlinkDestination;
}

Tags: InDesign

Similar Questions

  • Photoshop Elements 11, Windows 7 PC. When you try to make a Photo montage I get an error "not available for the creation of valid size.

    Hello

    Need help...  When you try to make a Photo montage I get an error "not available for the creation of valid size.

    Photoshop Elements 11, Windows 7 PC.

    Thank you

    Error "not available for the creation of valid size.

  • Windows XP keep getting an error code 0xD59 for the Service Pack to update KB2463332 & will not update?

    I get an error code 0xD59 for the update of Service Pack KB2463332?  Then he wants to resart my computer for an update failed?  Why?

    Hello


    Click on the below mentioned link to manually install the update on your computer.

    Microsoft SQL Server 2005 Express Edition Service Pack 4 for Windows XP.
    http://www.Microsoft.com/en-US/Download/details.aspx?ID=184
    After you install the update, restart your computer and check if the problem is resolved.
  • I'm doing a windows update and I get Windows could not search for new updates... errors found... Code 80244019

    I'm doing a windows update and I get Windows could not search for new updates... errors found... Code 80244019... Can someone help me please

    How to troubleshoot problems connecting to Windows Update or Microsoft Update https://support.microsoft.com/en-us/kb/818018

  • Error - exception error not supported for user - Help!

    Hi all

    I get an exception error unsupported to the user in a part of my page is refreshed after encountering a validation error.  Validation is managed properly, but when the page is refreshed to display I get an exception error not support for the user for the following code (generates the value of the element on the page):

    < code >

    Select nvl (sum (po_details.po_det_amt), 0)

    of po_details

    where po_details.po_id =: P230_PO_ID

    and po_details.wbs in (select distinct wbs_number_id of wbs, project

    where wbs.vendor_id =: P230_VENDOR

    and substr (wbs.wbs_number_id, 1, 6) = project.wbs_sequence

    and project.project_number = nvl (:F101_FPC_NUMBER,project.project_number));

    < code >

    When the code retrieves a single value, the following post calculation calculation of:

    < code >

    to_char(:P230_PO_AMT_FPC,'FML999G999G999G999G990D00');

    < code >

    Generally, the process works.  It is only when a validation run which prevents the removal of a purchase order that I encounter an error during a refresh of the page.  I get an exception error unsupported to the user for this calculation.  I'm puzzled.

    Any ideas?

    to_char(:P230_PO_AMT_FPC,'FML999G999G999G999G990D00');

    AFAIK - all within the APEX bind variables are of type VARCHAR2

    That means - you are implicitly expressing a string to a different data type just to cast to a string.

    So: this code is completely useless and adds more complication to the mix only what you need.

    It is very possible that Oracle is trying to convert a DATE... (which will fail)

    I put either the FORMAT for the type of element to match what you need or make the conversion from the string in your SELECT statement.

    for example

    Select to_char (nvl (sum (...), 0), "FML999G999G999G999G990D00")

    If you still get a 'user defined error', it is likely to be lifted since within the procedure used to remove the PO.

    See the DEBUGGING within the APEX pages to check exactly where the error is thrown.

    (it sounded like you already did and have reduced in to_char() section)

    MK

  • How can I get the script to a Table?

    Hello world

    Greetings

    We can get the script from the procedure, function, package, and trigger data dictionary see user_source.

    Is he see everything in the script for the Table? If not possible how to get the script for a Table?

    IndiMinds wrote:

    Hello world

    Greetings

    We can get the script from the procedure, function, package, and trigger data dictionary see user_source.

    Is he see everything in the script for the Table? If not possible how to get the script for a Table?

    http://docs.Oracle.com/database/121/ARPLS/d_metada.htm

    DBMS_METADATA. GET_DDL

  • I'm trying to timestamp (RFC 3161) a pdf file using my own timestamp server equipment but still get an error: 'invalid certificate for use.

    I'm trying to timestamp (RFC 3161) a pdf file using my own timestamp server equipment but still get an error: 'Invalid certificate for use' (text Original - certificado valido para uso e nao pt_BR:O). How can I get more information on what I'm missing or whats wrong with the certificate?

    I found the answer to my problem: it was linked to the plug of the TSA and its attribute 'Extended Key use '.

    In any case, thanks for your help. Just to answer the questions:

    Version: Adobe Reader XI

    Tried both:

    (A) the time stamp for the signature: signature put under without timestamp and an alert

    (B) the document timestamp: no changes and an alert

  • How to get the script to a table or view in SQL Developer?

    Dear friends/expert,

    Could you tell me how to get the script from a view or a table easily in SQL Developer as pressing F4 in TOAD?

    I found that I can press SHIFT + F4 to view in SQL Developer and get the script of the view in the Details tab. But how to move the script to the SQL worksheet to change? It is very easy to do in TOAD.

    And I have not found a way to get the script for a table up to now. Is it possible to do?

    Thanks in advance.

    Best regards
    Ning

    There are people a lot better out there to answer on this point than I am - but here's how I do it.

    I'm just in the browser/browser for interest table, choose the script on the right side tab (which shows all the SQL for the table) and then cut and paste what I want or need in my editor window.

  • How can I get the script all the tables and the reference system?

    Hello

    I'm trying to get the scripts of all the tables in my exquema MADE. Please can someone help me?

    Try this - the first script creates a 'tab_ddls' table to hold the table DDLS and second script generates the DDL and stores in this "table"tab_ddls ":

    {code}
    create the table tab_ddls (table_name, varchar2 (50))
    table_ddl clob)
    /

    declare
    cursor tab_cur is
    Select table_name
    from all_tables
    where owner = "MADE";
    CLOB table_ddl;
    Start
    for rec in tab_cur
    loop
    Select dbms_metadata.get_ddl ('TABLE', rec.table_name, 'MADE')
    in table_ddl
    Double;
    insert into tab_ddls (rec.table_name, table_ddl) values;
    end loop;
    dbms_output.put_line ('done');
    commit;
    end;
    /

    Select * from tab_ddls
    /

    {code}

    Please modify the script to fit your needs.

    HTH

    Published by: user130038 on August 2, 2011 11:08

  • My work laptop crashed and I want to install PhotoShop CS4 on a working PC I get an error msg "License for this product has expir├⌐.

    My work laptop crashed and I want to install PhotoShop CS4 on a working PC I get an error msg "License for this product has expiré.

    Error "licensing for this product has expired" | CS4, CS5

  • Error - &amp; &amp; operator is not defined for the java, type arugument lagn.string

    Hi all

    I am new to this forum and also java.
    Here is my program
    Please let me know the fix for this error

    Thank you
    Guna

    The logic is, I want to check the customer first, last and middle name.

    Senario 1: I want to check the name of the customer, if he gives only the NAME
    Senario 2: I want to check the name of the customer, if he gives the last NAME only
    Senario 3: I want to check the name of the customer, if he gives only the NAME
    Senario 4: I want to check the name of the customer, if he gives the first name and last name - this wher I get my error






    My coding

    self-learning package;
    Import Java.util;
    public class CustomerUtil {}

    Boolean SearchCustomer (List < Customer > listObj, customer cust)
    {

    Iterator listOfCustomerObj = listObj.iterator ();
    Customer cust1 = null;
    While (listOfCustomerObj.hasNext ())
    {
    cust1 = listOfCustomerObj.next ((customer));
    }

    If (cust1.getFirstName (.equalsIgnoreCase (cust.getFirstName ())))
    {
    System.out.println ("found customer");

    }
    If (cust1.getLastName (.equalsIgnoreCase (cust.getLastName ())))
    {
    System.out.println ("found customer");

    }

    I get the error message here, how to fix this error. Please let me know is there any other want to rewrite this condition.

    If (cust1.getFirstName () & & cust1.getLastName () .equalsIgnoreCase (cust.getFirstName () & & cust.getLastName ()))
    {

    System.out.println ("found customer");
    }

    Returns true;
    }


    }

    Matt wrote:
    People
    I'm new to this forum and also in java.

    I'll post any coding.
    I tried to put the code tag but his does not work. Sorry
    I saw the link, but I can't do it.

    Here is my code

    private static final int FIRST_NAME_MATCH = 1,
                             LAST_NAME_MATCH = 10,
                             WHOLE_NAME_MATCH = 11;
    int SearchCustomer( List listObj , Customer cust ) {
      Iterator listOfCustomerObj = listObj.iterator();
      Customer cust1 = null;
      int matchCount = 0;
      while(listOfCustomerObj.hasNext()) {
        matchCount = 0;
        cust1 = listOfCustomerObj.next();
        if ( cust1.getFirstName().equalsIgnoreCase( cust.getFirstName() ) )
          matchCount += FIRST_NAME_MATCH;
        if ( cust1.getLastName().equalsIgnoreCase(cust.getLastName() ) )
          matchCount += LAST_NAME_MATCH;
        if (matchCount == WHOLE_NAME_MATCH) break;
      }
      return matchCount;
    }
    

    The light of the foregoing, it is my best guess at what you describe you want. But it is not really make sense unless you think that you want the first person who is on the first and last names; what you could do to help eliminate the duplicates. But if this is the case you should consider a set instead of a list as they are not duplicates is added in the first place.

    Maybe you can take some ideas from this property. But if you want to match each person with the immediately previous person, then you must edit the item of the loop by removing of this method and put it in the method that calls this method, passing the two customers only and comparing them, or something like that.

  • VMkernel journal peripheral qualifier suggests 0 x 1 errors not supported for the MD3000i railways

    I have a vSphere cluster connected to the MD3000i and its configured by the book on two different subnets for each port on each controller. Robin is enabled for multi pahing on VC.

    That's what I see in newspaper vmkernel

    21 sep 16:19:29 db-esx2 vmkernel: 6:04:15:02.613 cpu4:6882) ScsiScan: 839: Path 'vmhba33:C0:T0:L0': seller: "DELL" model: Rev 'MD3000i': '0735' "»

    21 sep 16:19:29 db-esx2 vmkernel: 6:04:15:02.613 cpu4:6882) ScsiScan: 842: Path "vmhba33:C0:T0:L0": Type: 0 x 0, rev ANSI: 5, TPGS: 0 (none)

    21 sep 16:19:29 db-esx2 vmkernel: 6:04:15:02.613 cpu4:6882) ScsiScan: 105: path 'vmhba33:C0:T0:L0': peripheral qualifier 0 x 1 not supported

    21 sep 16:19:29 db-esx2 vmkernel: 6:04:15:02.618 cpu4:6882) ScsiScan: 839: Path 'vmhba33:C1:T0:L0': seller: "DELL" model: Rev 'MD3000i': '0735' "»

    21 sep 16:19:29 db-esx2 vmkernel: 6:04:15:02.618 cpu4:6882) ScsiScan: 842: Path "vmhba33:C1:T0:L0": Type: 0 x 0, rev ANSI: 5, TPGS: 0 (none)

    21 sep 16:19:29 db-esx2 vmkernel: 6:04:15:02.618 cpu4:6882) ScsiScan: 105: path 'vmhba33:C1:T0:L0': peripheral qualifier 0 x 1 not supported

    21 sep 16:19:29 db-esx2 vmkernel: 6:04:15:02.623 cpu4:6882) ScsiScan: 839: Path 'vmhba33:C2:T0:L0': seller: "DELL" model: Rev 'MD3000i': '0735' "»

    21 sep 16:19:29 db-esx2 vmkernel: 6:04:15:02.623 cpu4:6882) ScsiScan: 842: Path "vmhba33:C2:T0:L0": Type: 0 x 0, rev ANSI: 5, TPGS: 0 (none)

    21 sep 16:19:29 db-esx2 vmkernel: 6:04:15:02.623 cpu4:6882) ScsiScan: 105: path 'vmhba33:C2:T0:L0': peripheral qualifier 0 x 1 not supported

    21 sep 16:19:29 db-esx2 vmkernel: 6:04:15:02.628 cpu4:6882) ScsiScan: 839: Path 'vmhba33:C3:T0:L0': seller: "DELL" model: Rev 'MD3000i': '0735' "»

    21 sep 16:19:29 db-esx2 vmkernel: 6:04:15:02.628 cpu4:6882) ScsiScan: 842: Path "vmhba33:C3:T0:L0": Type: 0 x 0, rev ANSI: 5, TPGS: 0 (none)

    21 sep 16:19:29 db-esx2 vmkernel: 6:04:15:02.628 cpu4:6882) ScsiScan: 105: path 'vmhba33:C3:T0:L0': peripheral qualifier 0 x 1 not supported

    I see this on the two hosts vmkernel journal...

    should I be worried. "This isn't necesserely showing error but:" device qualifier 0 x 1 not supported "gets my attention.

    If you have NOT of LUNS assigned as Lun0 then you will get this error.   So always start with LUN Lun0 aka: Lun0 - first record entrust you, Lun1 - second disc etc.  You have not neccessarly to reallocate your currently lun, you could create a new lun and presenting it as Lun 0.     So try that if you are able to create a new Lun.   Otherwise if you have existing virtual machines running on the current Lun5 you would have to stop them, being cancelled at them in inventory, change the Monday from 5 to 0 and then re-record their I think.    Also, make sure that you do not jump also any number of LUNs... aka go Lun0, Lun1 and Lun2 Lun3 etc.

  • ReferenceError: vm is not defined for the wait for the DNS name?

    Has anyone seen this message before? I just started to receive when I try to build our vCenter our Dallas vCAC California machines. This happens during the commissioning and is taken on an Action of "vim3WaitToolsStarted". Is - it may expire due to the latency? He manages to pass the stage of construction and the name is defined very well.

    Edit: I can build local machines very well. It is only during the construction of machines in California I get this error.

    Edit2: I notice that VC:VirtualMachine wants to say "Undefined" while others such as the vCAC:VirtualMachine show the name of the virtual machine. The action of the vim3Waittoolsstarted requires VC:VirtualMachine. I have no idea why vCAC would not pass this info to a set of machines over another?

    While you wait, I recommend this change (this is the new default and VMware has recommended to several people in the 6-9 months): check /etc/vco/app-server/vmo.properties (or find the file if don't use only not the vCO device) and add the following line (if not present): com.vmware.o11n.vim.useInventoryService = false

    Then you can re - try and see if it works... The inventory service is bad juju with some calls in more recent versions of the vSphere plugin, and that will be the value default value moving forward (I think starting with 5.5.2? Don't remember).

    That could put you straight.

    -Steve

  • I get an error "Runtime c +" for "spoolsv.exe".

    I was always told not to download any what registry tools so how can I fix this on my own?

    Hello

    1. when exactly you get this error?

    2. What is the full error message?

    3. you remember to make changes to the computer before this problem?

    Errors caused by the spoolsv.exe file are often caused by other third-party software programs installed on the computer or the printer drivers installed on the computer.

    Make sure you have the latest printer drivers for your printer. In addition, make sure you have anti-virus protection on computer software and that it is up-to-date.

    You can connect the site of the printer manufacturer for the latest drivers for the printer.

    Check out the link:

    Update drivers: recommended links

    http://Windows.Microsoft.com/en-us/Windows-Vista/update-drivers-recommended-links

    Hope this information is useful.

  • Set connection error not reliable for a secure site when you use a standard account in Vista, but not administrator.

    I am trying to log on to the EZ Pass New York site, but I get this error of no reliable connection for the last days. More precisely, it is say no issuer channel was provided with the error code: sec_error_unknown_issuer. Previously, it worked fine. This only happens with the standard user accounts in Windows Vista for Firefox. It doesn't happen when I use the account administrator or IE on each account. What is happening and how to fix it? Appreciate any help you can offer.

    He himself seems to have resolved now. Beats me why.

Maybe you are looking for