Object is invalid on object.parentStory.characters.item(i+1).fontStyle;

Hey guys,
I have an array where I save the contents of a textFrame, where "object" is the textFrame.
textContent = object.contents;
Then I have a for loop to loop  through all items. With
if(i > 0)
object.parentStory.characters.item(i-1).fontStyle.toString().toLowerCase();
object.parentStory.characters.item(i).fontStyle.toString().toLowerCase();
if(i < textContent.length-1)
object.parentStory.characters.item(i+1).fontStyle.toString().toLowerCase();
I am getting the previous, current and next styles. It's for xml purposes and with this I can add a "<b>" , "<i>", etc. tag for my objects. The problem occuring now is that on some point, object.parentStory.characters.item(i+1).fontStyle; returns "object is invalid".
That being said, item(i+1) is valid. If I alert this, it says "object [character]". I tried to use if(object.parentStory.characters.item(i+1).hasOwnProperty('fontStyle')), but it didn't work. I don't know why it throws this error and I couldn't find any solution to this problem on the web.
Has anybody experienced this?  Here is the complete code(without italic and bold italic):
function spliceSlice(str, index, count, add) {
  return str.slice(0, index) + (add || "") + str.slice(index + count);
function checkFontStyle(object){
    textContent = object.contents;
    for(i = 0; i < textContent.length; i++){
        style = object.parentStory.characters.item(i).fontStyle.toString().toLowerCase();
        if(i > 0)
            prevStyle = object.parentStory.characters.item(i-1).fontStyle.toString().toLowerCase();
        if(i < textContent.length - 1){
            nextStyle = object.parentStory.characters.item(i+1).fontStyle.toString().toLowerCase();
        if(style.indexOf('bold') > -1){
            if(prevStyle.indexOf('bold') > -1){
            else if(nextStyle.indexOf('bold') < -1){
                textContent.spliceSlice(textContent, i, 0, '[/b]');
            else{
                textContent = spliceSlice(textContent, i, 0, '[b]');
    return textContent;
The desired behaviour would be, that if the current object has no "fontStyle" it should just skip this iteration.

be carefull with var totalPages = parseInt(app.activeWindow.activePage.name);
the pagename can be (for ex.) "MXIV", if you use roman numbering.
use .documentOffset to be on the safe side.

Similar Messages

  • JS :Object is Invalid

    Hi all
    I want to insert footnote at the end of text.
    When i run my java script give error object is invalid at line no 7.
    #target indesign
    var myDocument = app.documents.add();
    var myTextFrame = myDocument.pages.item(0).textFrames.add();
    myTextFrame.geometricBounds = ["6p", "25p", "30p", "30p"];
    myTextFrame.contents = "Indesign";
    var word  =myTextFrame.parentStory.words.item(1);
    var insertionPoint=word.insertionPoints.item(-1);    // give error  at this line Object is invalid
    var footnote=insertionPoint.footnotes.item(1).add(at(1701733408));
    footnote.setContents("FirstFootnote");
    myDocument.FootnoteOptions.setEosPlacement(1);
    Thanks.

    Thanks Jump_Over for reply
    There is another problem in my Script in the selection of Image place in textframe. I am not understand this problem also. It give error  Undefined is not an object   in 5th line.
    myTextFrame = myDocument.pages.item(1).textFrames.add();
    myTextFrame.geometricBounds = ["20p", "25p", "30p", "35p"];
    myTextFrame.place(File("/C/version.jpg"));
    var graphic=myTextFrame.allGraphics.firstItem;
    graphic.select("SelectionOptions.REPLACE_WITH");  // give error Undefined is not an object
    graphic.geometricBounds = ["20p", "25p", "30p", "35p"];
    if I use this line
    var graphic=myTextFrame.allGraphics.item(1).select("SelectionOptions.REPLACE_WITH");
    then it give error
    myTextFrame.allGraphics.item is not a function
    Thanks.

  • [CS4 - JS]Export stories and "object is invalid" error

    Hello all,
    I need a javascript script that exports all the stories of a document to .icml files.
    At the moment I've come to a function like this:
    function exportICML(myDoc, path) {
            var stories = myDoc.stories;
    for (var i = 0; i < stories.length; i++) {
          alert(i);
          var story = stories.item(i);
          var filename = path + "/story-" + i + ".icml";
          try {
               story.exportFile(ExportFormat.INCOPY_MARKUP, new File(path));
                 } catch (err) {
    alert(err.message);
    This function fails, and in the server log I see this error:
    "Object is invalid"
    What am I doing wrong?
    Thanks.

    Works fine here :S
    var myDoc=app.activeDocument;
    var myPath = Folder.desktop+"/test.icml";
    exportICML(myDoc, myPath);
    try storing theend of loop outside the function and renaming var to avoid DOM names collision.
    function exportICML(myDoc, path) {
            var allStories = myDoc.stories;
    var iMax = allStories.length;
    for (var i = 0; i < iMax; i++) {
          alert(i);
          var myStory = allStories.item(i);
          var filename = path + "/story-" + i + ".icml";
          try {
               myStory.exportFile(ExportFormat.INCOPY_MARKUP, new File(path));
                 } catch (err) {
      alert(err.message);

  • Object Class Invalid when downloading the pricing procedure from ECC to CRM

    Hi,
    I want to download the pricing procedure for that I have created the ZDNL_CUST_CND which contains only the following tablesT683, T683S, T683T and T683U.
    When I check in R3AM1 status is Red.
    The following Error have been found in SLG1
    •     Object class invalid
    •     Error in inbound data check
    Message no. CND_MAP120
    Diagnosis
    During the receiving inspection, serious errors were found in the consistency of the exchange object.
    System Response
    Data exchange is terminated
    •     Data exchange terminated     
    Message no. CND_MAP122
    Diagnosis
    Data exchange has been terminated due to serious errors. No exchanged data has been posted in the system.
    The following Error has been found in SMQ1
    •     R3AD_CONDITIONS     STOP
    Details of STOP
    Set by Host name: litldq; Transaction: ; Report: SAPMSSY1
    I have checked the connection, everything is perfect.
    What may be the problem?
    Thanks

    Hi,
      Please try to re-generate the adapter object (ZDNL_CUST_CND) services using trx.
    SMOGGEN
    . After this, try re-running the load.
    I assume that your CRM inbound mapping module are correctly coded. If the problem persists, try de-registering the R3AD_CONDITIONS inbound queue using trx.
    SMQR
    and then debugging the inbound queue from the same trx. after re-starting the load.
    Reward if this helps!
    Regards,
    Sudipta.

  • Acrobat.exe closed by Windows & "invalid annotation object"

    While I am editing comments with Acrobat 9.3.1, I get a Windows error "acrobat.exe ..... closed by Windows"
    Then when I open the PDF document, I get "invalid annotation object" error, and the file is corrupted and not usable any more.
    Please advise me what steps I need to take to this frequent errors on my computer.  Thanks.

    I too had a Multi Page PDF that had the same "invalid annotation object".
    I was able to open & use the damaged  using Tracker Software - PDF Viewer - PDFXCview (free software - Google it)
    The file opened without error in PDFXCview and I was able to save it, but reopen in Acrobat still had the error.
    I re-opened it in PDFXCview and deleated the comments on the page that Acrobat reported the "invalid annotation object", and was able to save the file, which now opens in Acrobat without the error.

  • "Invalid Annotation Object" error

    I'm using Windows XP Pro (SP3) on a 2.66 GHz, 2 GB RAM computer, and while working in an Adobe Acrobat 9 document, I had just saved the file (CTRL+S) and the document froze and I got a Windows error box that asked if I wanted to send an error report, which I did. When I opened Adobe again, it asked if I wanted to open the last file which didn't save correctly, which I did.
    Then when I proceeded to work in the document and tried to highlight a sentence I was going to delete, I got an Adobe Acrobat popup box that said "Invalid Annotation Object. OK" but no matter how many times I clicked on "OK," the box kept popping up and wouldn't go away. I tried saving a copy of the document, but the same box was in it and wouldn't go away. I couldn't even work in the document to extract pages or anything else. Huge problem!
    Does anyone know what can I do to resolve this problem? (This happened on a Saturday when Adobe phone support is not accessible.)

    On 3/24/2015 same problems, after Adobe Acrobat 9 pro. crashed while I added text boxes.. When I opened Adobe again, Yes to open the last file which didn't save correctly, then "Invalid Annotation Object" errors on my .pdf file of 96 pages
    - first, I had to acknowledge/click the OK button until all " invalid annotation objects" error pop-up windows are gone
    (for my file with 96 pages, i had to hit the OK button more than hundreds times - need patience)
    - then found out (later) that what I did turn out to be the same steps as following post by davidsdomingo in adobe.forums
    davidsdomingo May 28, 2009 1:39 PM (in response to (Holger_Wulf))
    Here is a technique for identifying all the pages that have invalid annotation objects on them:
    1. Document > Extract Pages ...
    •Select the checkbox for "Extract Pages As Separate Files"
    •Set the destination to a 'dedicated' folder that won't contain any other files -- that way, you can simply delete the folder when this process is done.
    •Click OK.
    2. During the extraction, click OK in all the message boxes that appear.
    3. After the extraction, look in the destination folder to see which pages are missing. Those are the pages that have invalid annotation objects.
    From this point you can try to delete the objects, or simply delete and replace the pages, or implement a different solution. Hope this helps someone.
    - after extract the 96-pages file into individual files into a dedicated folder, only 95 got extracted and page 1 was not/can not be extracted.
    - I then combined the 95 good extracted pages into a new file name .pdf
    - then inserted a good page 1 without error (from the file that was saved previous day, prior to all the changes I made on the corrupted file), re work on page 1
    - delete the bad file.
    Hope this helps someone.

  • "Invalid annotation object" on only two of six computers.

      When searching for the resolution to this error I keep seeing that the PDF is corrupt when people get the error "Invalid annotation object".  But I have a office that has eight workstations and only two are getting the error.  To further complicate issues I downloaded Adobe Reader on one of the machines and it does not get the error either.  All of the machines on the network are using Adobe Acrobat 9.
    The steps we have taken to try to resolve the issue on one of the computers:
    Ran the repair of Adobe from the help.
    Checked for updates.  None were found, it was fully updated.
    Downloaded malware scanners - RKill, Malwarebytes and AdwCleaner.  All found nothing.
    Removed Adobe Pro and tried Adobe Standard.
    After all these steps we still get the error on the machine, but if we go to the computer in the next room it will open it fine with no errors.  We can also open the same document on that computer with Adobe Reader and get no errors.
    One way to bypass the error is to use the arrow keys to navigate the document.  The error only happens when navigating by using the mouse.
    Any and all help would be greatly appreciated.
    Thank you.

    Jenny,
    Look at where the problem computer is getting its time/date from (System Preferences>Date/Time), then compare that to one of the functional computers. It might not be syncing up with the Exchange server time-wise, which will cause problems.
    Good luck

  • Adobe "Invalid annotation object" error

    We recieve a specific error message on a few PDFs. Some from documents converted from 2007 Word and others out of Outlook 2007 through the PDF print function.  While moving the mouse over certain comments the users has placed on the document in the PDF format, Acrobat 9.9.3 throws this error. We've tried to delete the bad refs and other times have just started a new document, print to PDF while starting over.  Any ideas on why this is happining, what might be causing this and what we can do to reslove this problem.  I cannot seem to duplicate the problem a few see.  Any thoughts or solutions would be greatly appreciated. Best regards, Brian

    On 3/24/2015 same problems, after Adobe Acrobat 9 pro. crashed while I added text boxes.. When I opened Adobe again, Yes to open the last file which didn't save correctly, then "Invalid Annotation Object" errors on my .pdf file of 96 pages
    - first, I had to acknowledge/click the OK button until all " invalid annotation objects" error pop-up windows are gone
    (for my file with 96 pages, i had to hit the OK button more than hundreds times - need patience)
    - then found out (later) that what I did turn out to be the same steps as following post by davidsdomingo in adobe.forums
    davidsdomingo May 28, 2009 1:39 PM (in response to (Holger_Wulf))
    Here is a technique for identifying all the pages that have invalid annotation objects on them:
    1. Document > Extract Pages ...
    •Select the checkbox for "Extract Pages As Separate Files"
    •Set the destination to a 'dedicated' folder that won't contain any other files -- that way, you can simply delete the folder when this process is done.
    •Click OK.
    2. During the extraction, click OK in all the message boxes that appear.
    3. After the extraction, look in the destination folder to see which pages are missing. Those are the pages that have invalid annotation objects.
    From this point you can try to delete the objects, or simply delete and replace the pages, or implement a different solution. Hope this helps someone.
    - after extract the 96-pages file into individual files into a dedicated folder, only 95 got extracted and page 1 was not/can not be extracted.
    - I then combined the 95 good extracted pages into a new file name .pdf
    - then inserted a good page 1 without error (from the file that was saved previous day, prior to all the changes I made on the corrupted file), re work on page 1
    - delete the bad file.
    Hope this helps someone.

  • Invalid DataStore object name /BIC/B0000173: Reason: No valid entry in tabl

    Hi gurus,
         I recently transported the 0FI_GL_10 datasource to preproduction. when i am trying to load the data in PrePod we are getting this error message.
    <b>Invalid DataStore object name /BIC/B0000173: Reason: No valid entry in table RSTS</b>
    Any help is appreciated with points.

    any more detailed messages,sm21 or st22??
    did you try doing RSRV on the datastore object??
    are you using the nw2004s data flow??
    if using 3.x data flow ,skip PSA and try reloading it.
    Hope it Helps
    Chetan
    @CP..

  • Invalid tincan object name

    I am trying to stream video from a Flash Media Server using
    AS3. I am getting an error that I cannot figure out. In my
    NetStatusEventHandler I am getting event code
    "NetStream.Play.Failed". The error is: "Invalid tincan object name
    (stream ID: 1)" This means absolutely nothing to me and I have been
    unable to find any documentation on the meaning of this error.
    ISSUE RESOLVED: I was including the filename in the
    netconnection.connect method's URI
    NOTE: I have also posted this in the Flash Media Server forum
    as I was unsure where this question best fit.

    Glad that you figured it out. Here are a couple of things
    that could help in the future. It would have helped if you had
    posted the code you were using. Somebody would probably have seen
    something like that right off.
    The other thing is that it is helpful if you don't edit
    posts, but rather make a new one. Folks who use Newsreaders on the
    forum don't see the edits.

  • Invalid DataStore object name /BIC/B0005712

    Hi Frnds,
    I was trying to execute a PSA deletion step on one Datasource. In that process I got the below error.
    Error msg: Invalid DataStore object name /BIC/B0005712: Reason: No valid entry in table RSTS.
    Do, I need to maintain anything related to this Datasource in the table RSTS. if so....what it could be ?
    Or Do we have any other solution ?
    Thank you.
    NGR.

    Hi,
    In my case,
    Inspite of going through several valid NOTES & program, my issue didnt resolve.
    I have resolved the issue by adjusting the PSA table for the same.
    Procedure:
    Take the psa name  --> go to table rstsods --> find the ODSNAME_TECH name for the relevant psa  --> se38 t.code --> enter ODSNAME_TECH and click on 'adjust & activate database table' (make sure you have selected 'save data' radio button.
    Just in case anyone who come across this problem, can do the above steps.
    Regards,
    Dubbu.

  • Error: demo.model.AppModule: Application module demo.model.AppModule has a view instance EmpByEmail1 that references an invalid view object.

    Error: demo.model.AppModule: Application module demo.model.AppModule has a view instance EmpByEmail1 that references an invalid view object.
      intially i created view object named EmpByEmail.........for that EmpByEmail1 is created in datacontrols....i deleted EmpByEmail in demo.model by mistake and i created again with same name EmpBYEmail another view object...again another EmpByEmail2 is created in datacontrols.....
    while i am running i am getting following error:::::::
    Error: demo.model.AppModule: Application module demo.model.AppModule has a view instance EmpByEmail1 that references an invalid view object.

    Hi,
        Please seasrch for the EmpByEmail1 file in ur project and remove all the details in the Page Def and UI and then try again.
    Due to the EmpByEmail1 existance in page Def this may occur . It may help , still if it was not working then I am sorry for that.

  • Invalid DataStore object name error when running process chain after EHP1

    Hello,
    We recently upgraded our BW Dev platform to NW7.01 EHP1 SP6. I noticed that the layout for "Delete PSA Request" process in the Process Chain has changed after the upgrade. We can no longer specify the actual PSA table to delete eg, /BIC/B0001645. Instead we need to specify the Datasource name and the Source System.
    Now after the upgrade when I run one of my process chains, it fails at "Delete PSA Request" step with error message "Invalid DataStore object name /BIC/B0001645: Reason: No  valid entry in table RSTS". This datasource is based on the flat file source system and the PSA table for this Datasource is /BIC/B0001653.
    Unfortunately the process chain is picking up an older PSA table for this datasource and there is no way for me to specify the current PSA table name after this change in layout with EHP1 upgrade. Any suggestions on how to resolve this issue.
    Many Thanks,
    Al

    Hi,
    Please implement OSS 1345331.
    If this does not help try the below steps:
    1.  Run the report 'RSAR_PSA_CLEANUP_DIRECTORY/_MS' in check mode for a 
           particular PSA table for finding the inconsistencies.
    2.   After that please analyze the logs and if there is any problems related to partition, you need to correct them using the report u2013
    3.  'SAP_PSA_PARTNO_CORRECT' in repair mode for the
          PSA tables.  Run the report again after this
    4.  'RSR_PSA_CLEANUP_DIRECTORY/_MS' in check mode to 
         double check that the invalid partitions are 
         corrected.
         Once this is done you can execute the report     
         'RSR_PSA_CLEANUP_DIRECTORY/_MS' in repair mode.
    -Vikram

  • Error "Invalid Report Object" when running any CR

    Hi, I have installed BO XI V3.1 and upgraded to 1.4 level.
    However when logged into the infoview app, if i browse to any 2008 report i have uploaded into the enterprise system and double click to run i get the error "Invalid Report Object".
    This is also true if i try to run any report in the Public Folders \ Report Samples folder.
    Nothing will display for me but they run fine in CR 2008, just not via the web tool.
    Any help on this will be much appreciated.
    C.

    Hi,
    Is this issue after you have upgraded to 1.4 or was this issue occurring before?
    Since the reports are running properly in the designer please try to do following steps:-
    1)  Open the report in the designer which is not working in enterprise
    2)  Refresh the report in CR designer
    3)  Save the report back to the enterprise and make sure save with data is checked.
    4)  Now open the report in the Enterprise and check it works or not.
    The reason of doing this is that to generate new PID's for the reports if after the upgrade the PID's have changed or has became corrupt.

  • How to fix the .pdf file with error "invalid annotation object"

    how to fix the .pdf file with error "invalid annotation object"

    As long as the PDF opens, then just try saving it to a new file name. There may be a preflight script that would help troubleshoot the issue.

Maybe you are looking for

  • How do I bring up my Itunes library from my PC to my new MAC?

    How do I bring up my Itunes library from my PC to my new MAC?

  • How do i make a button open a new window...

    Hi, I'm making some very basic login software and i want the program to open up a new window when the "Login" button is pressed and then display a message saying whether the login was successful or not. Any help would be appreciated but i would love

  • Basic Authentication for Non-AD Users

    Hello we are implemented windows integrated single sign on using spnego module and adjusted the login stacks as directed; Evaluate TicketLogin.Module = SUFFICIENT SPNEGO mdoule = OPTIONAL Ceate TicketLoginModule = SUFFICIENT BasicpasswordLogin Module

  • Accessing Crystal Reports 12 report from a CF7/8 Web Application

    Beside exporting the Crystal Reports 12 report to PDF, HTML, or some other doc format, does anybody have any experience with accessing a Crystal Reports 12 report in its native .rpt format? I've tried using cfreport, but with no success!?

  • X-Fi XtremeMusic - Floppy drive connect

    Hello An easy question - I have the XtremeMusic card, and have noticed a floppy dri've power connector on the board. Do I need to connect a floppy dri've power cable to the card? The manual for installation does not mention this. Thanks