When is a document valid

Hello,
I seem to be tripping up on some very basic stuff.
We install an event listener to detect selection changes. This works well if we manually close the palette. If we quit while the palettte is open we get an error saying we are accessing a document when there are not any open.
Here is the error. There is a document window.
The following code demonstrates the problem. In my opinion the alert should not display the documnet name when quiting but it does.
What is the best test to see if a document is valid.
Thanks.
P.
#targetengine "paltester";
main();
function main()
          var w = new Window( "palette", "pal test" );
          w.onShow = function ()
                    app.addEventListener("afterSelectionChanged", selectionChangedFunction);
                    return;
          w.onClose = function ()
                    app.removeEventListener("afterSelectionChanged", selectionChangedFunction);
                    return;
          w.show ();
          function selectionChangedFunction ( )
                    if(app.documents.length <= 0 )
                              return;
                    alert ( app.documents[0].name );
                    return;

Hi Pickory,
The event type afterSelectionChanged is associated to an Event whose target is usually a LayoutWindow (not a Document). When the document's window is closed, however, that event is probably triggered from the app (target). I'm not sure. Anyway, the error you get shows that the app.documents property is not yet updated—on Mac OS—when the event is notified. So, you should use a stronger condition (based on the event target), then try to access the active document if all is fine:
function selectionChangedFunction(/*Event*/ev)
    var doc,
        docName;
    if( ev.target instanceof LayoutWindow )
        doc = app.properties.activeDocument;
        docName = doc && doc.properties.name;
        alert( docName );
Hope that helps.
@+
Marc

Similar Messages

  • Pages 5.5.1: When opening a document created with Pages '09 (Version 4.0) with Pages 5.5.1 the page header and the page footer are deleted. How can this be prevented? Or is this a bug in Pages 5.5.1?

    Pages 5.5.1: When opening a document created with Pages '09 (Version 4.0) with Pages 5.5.1 the page header and the page footer are deleted. How can this be prevented? Or is this a bug in Pages 5.5.1?

    Same problem here (no graphics in header or footer) and the problem has been reported months ago. It is another bug/feature lost when Apple moves from 09 to the iCloud-compatible versions.  Complain to Apple, you may have better chance than me and they may finally listen to their users....

  • I am using Adobe XI Pro and in various parts of the document there is brown / biege lettering when on the document it shows as black.  My printer guy has been in and checked it out top to bottom and that part is fine.  I have tried to print the same docum

    I am using Adobe XI Pro and in various parts of the document there is brown / biege lettering when on the document it shows as black.  My printer guy has been in and checked it out top to bottom and that part is fine.  I have tried to print the same document and it comes out fine.  Any ideas ?   Using Windows 7 Service Pack 1

    Sorry my bad.  I have tried to print the same document on another printer and all the formatting is fine. 

  • FI-CA document type when a print document is created

    Hello everybody,
    We have been searching events (e.g. 0061)/user-exit to change the FI-CA document type when a print document (based on our own logic) is created with transaction EASIBI without success. Maybe you have enhanced something in another project. Can you share you experiences?
    Thanks in advance.
    Fernando.

    We have enhanced event R999.

  • Pages crashes when opening any document on iPad 3 Latest version.   I could find on the net and finally deleted Pages from my device and reinstalled it. Still when I try to create anew document or open a document it just cr

    Pages crashes when opening any document on iPad 3 Latest version. I tried everything I could find on the net and finally deleted Pages from my device and reinstalled it. Still when I try to create a new document or open a document it just crashes out.

    Try this:
    Make sure IOS is updated to latest version
    Reboot device by pressing both the home button and sleep/wake (power) buttons at the same time for 10-15 seconds until the apple logo appears on the screen, then let go.
    If that doesn't work then reset the device by going to settings/general/reset/reset all settings

  • How can I place my initials when in a document shared review?

    When in a document shared review envitronemnt, the Sign Document menu is grayed out, I want to be able to place my initials in
    a document, what are my options?

    The contents of the folder-level JavaScript file can simply be:
    // Create and set the value of the identity.initials property
    identity.initials = "GWJ";
    You can then retrieve the value in your dynamic stamp JavaScript to the the value of a field, something like:
    // Code in calculation of a text field in a dynamic stamp
    event.value = identity.initials;

  • I am getting error when hovering on document in sharepoint online "sorry there was a problem and we can't open this document.If this happens again, try opening the document in Microsoft Word"

     I am getting error when hovering on document in sharepoint online "sorry there was a problem and we can't open this document.If this happens again, try opening the document in Microsoft Word".I am sure that document is not corrupted and
    all. something it showing the preview and sometimes it throwing this error. I hope this error is intermident. When clicking on the link also it throws this error but on refreshing it working fine. I dont know why it is happening. Please helpme  to resolve
    this issue. 

    Hi Waqas
    Thanks for your help with this. I had a look at both posts, the URL works fine from the WAC server and I am not using a System account to test docs.
    Also, this is a production site that is accessible over the Internet, so we are using https therefore the WOPIZone is external-https.
    Issue #3 in the above blog link does not reflect the same error I see on my servers.
    I also had a look at the information in this link: http://technet.microsoft.com/en-us/library/ff431687.aspx#oauth
    Problem: You receive a "Sorry, there was a problem and we can't open this document" error when you try to view an Office document in Office Web Apps.
    If you added domains to the Allow List by using the
    New-OfficeWebAppsHost cmdlet, make sure you’re accessing Office Web Apps from a host domain that’s in the Allow List. To view the host domains in the Allow List, on the Office Web Apps Server open the Windows PowerShell prompt as an administrator and run
    the Get-OfficeWebAppsHost cmdlet. To add a domain to the Allow List, use the
    New-OfficeWebAppsHost cmdlet.
    I have not added any domains to the Allow list so this did not help either. Should I add the domain?
    Any further help with this is much appreciated.
    Thanks again.
    Yoshi

  • Recieving error when signing a document

    When signing a document, users are receiving >>Timestamp signature property generation error: Unsupported transport protocol
    Time Stamp Server is configued as Server URL:  IP Address of Time Server
    Any ideas on how to resolve this error?

    Hi,
    The problem is probably the URL for the timestamp server is an SSL address (i.e. https://) and the certificate that the OS needs to validate the SSL connection is not available. One thing to try is to copy the address for the timestamp server and paste it into a browser. This may give you the option of installing the SSL certificate.
    Steve

  • Error message when opening a document "this document is being used by another user

    error message when opening a document "this document is being used by another user, do you want to make a copy?
    I select yes, then new message - word can not open this document.the document might be in use or it may not be an invalid document.
    Any suggestions?

    Hello MrNeuf,
    I would recommend releasing and renewing the IP lease on the affected computer. The following article provides further information and details the process of doing so.
    Mac OS: How to release and renew a DHCP lease
    http://support.apple.com/kb/TS1920
    Cheers,
    Allen

  • How to have Windows Print prompt pop up when printing SBO documents

    Version 8.8 SP00 PL14
    I have SBO Print Preferences for Sales Order and AR Invoice set to NOT Print on Add.
    I have PLD layouts with defined printers assigned to users.
    I want the user to be able to change the defined printer when printing a document.
    I don't want the user to have to select a different PLD layout.
    When the user prints a document SBO is sending the document straight to the defined printer without popping the Windows Print screen that would allow the defaulting printer to be changed.
    Is there any way to make the Windows Print screen pop up?

    Hi Tony,
    I noticed too that when you now click on 'Print', the windows print window no longer comes up.
    Did you set the PLD template default by user and indicate in Print Layout Manager the correct printer for that layout? (i.e. looks like you need a layout for each printer if the printer is different by user unless the printer to be used is the user's default printer.)
    Heather

  • Asking for password when signing a document

    In Acrobat 9 standard, when signing a document with a Windows Digital Signature, how do you set it to ask for a password?

    The product acts for a password when it can't identify and verify the signer is supposed to have access to the signing certificate's private key. You can't control what happens on the signer's end in all cases. If you want to set restrictions on specific fields, look up "seed values" in the Dig Sig Guide.
    Ben

  • My adobe acrobat XI Pro has been constantly freezing when I open documents.

    My adobe acrobat XI Pro has been constantly freezing when I open documents. I've uninstalled and reinstalled the program, changed some settings based on community threads, nothing is working. I have to close the document, open it back up and wait at least 60 seconds before I can do anything. I use Adobe pdfs for everything this is very bad. I am using MS Office 365, and Adobe CC on Windows 8.1.

    Hi Kate,
    Please refer to this KB doc. for the solution Application, file icons change to Acrobat/Reader icon
    Let me know if the issue persist.
    Regards,
    Aadesh

  • InDesign cs3 crashes when opening CS2 documents

    ID cs3 crashes when opening CS2 documents, not when open dialog appears, but after I choose file and it "starts" opening it. (core duo, xp, clean install, all updates)
    If i open ID by opening file, it crashes with standard windows dialog, if I open ID first, it does not crash, but rather behaves strangely, nothing is opening, if I move a mouse it turns to sand clock.
    Same thing happens on all machines with ID cs3 in my office.
    All other apps works fine. I did read every single forum about ID crashing and nothing helps. Files resaved in interchange format opens well. There must be something in the files that ID cs2 did and what id cs3 cannot open :( Any ideas?

    1. Is there any reason to use eps? Avoid it use AI, PSD or PDF instead.
    2. Are all used fonts ok? What kind of fonts du you use?
    3. Which Mac OS X do you use?
    Does it crash with alwayst the same files?
    What does the file history tell you? Hold down the command key and got to InDesign > About InDesign… Does it tell you somewhat more specific, like missing plugins, severly damaged files and restored files, when (in which version) the files have been created first (helps often to export to IDML and open this again and save it as INDD and work with the new file.), has the problematic file been converted from another application (Quark Xpress or PageMaker), etc.

  • Just upgraded my system to snow leopard...now when I open documents from my memory stick, its in 'pages' not word...how do I fix that??

    Just upgraded my system to snow leopard...now when I open documents from my memory stick, its in 'pages' not word...how do I fix that??

    Did you click on the little triangle? Did you select one of the document files before pressing COMMAND-I to open the Get Info window? If the panel is closed it looks like this:
    If you then click on that little triangle gadget you get this:
    A temporary solution is to CTRL- or RIGHT-click on the document file, navigate to the Open With item, and select from the sub-menu.
    The first method makes the association permanent. This method only applies to the currently selected document.

  • Acrobat crashes when closing a document.

    I have developed a simple Acrobat Addin, which adds a menu item and a toolbar button. The active document will be closed when this menu item or toolbar button is clicked.The document is closed using the function "AVDocClose".
    Acrobat crashes when AVDocClose is invoked from toolbar button and works fine when invoked from menu item. This happens only when "Show each document in its own window" is checked and in the version 8.0 Professional. Works fine in 7.0. The crash has occured in Acrobat.dll.
    Is this crash a known Acrobat issue in 8.0?
    OS : Windows XP
    Thanks,
    Partha

    The only  plug-ins installed are the default ones that came installed with Acrobat.  All of these are developed by Adobe, so i'm assuming your are not referring to these as "3rd party".  All custom plug-ins have been uninstalled with the exception of the Stamper sample to test this theory.  Quite literally this can be reproduced by adding  the following code to the "ToolActivate" method in StamperUI.cpp.  This is the method that is wired into both the MenuItem and Button click events by default in this sample.  When this code is executed by a MenuItem event, no issue at all.  When this code is executed by a button click event, an exception is thrown from Acrobat.exe.  Note that the exception is not thrown from the ToolActivate method, it is thrown at some point after this method completes.
    AVDoc avDoc = AVAppGetActiveDoc();
    if (avDoc != NULL)
    AVDocClose(avDoc, true);
    As you can see, no objects are being acquired in this code.  If AVDocClose is not executed, no issues at all.  Although that goes against what i am attempting to do (as a result of a Button click, i need to be able to close the AVDoc).
    Any thoughts as to root cause of this issue?
    Karl, i really appriciate your assistance!  Thanks.

Maybe you are looking for

  • How to download adobe acrobat pro

    I have a new computer, how can I download Acrobat Pro and use my subscription to log in?

  • ITunes freezes every time iPhone (2.0 software) is connected!

    I just recently updated iTunes to 7.7 and then updated my original iPhone to 2.0 software. Since the update to 2.0, iTunes on my laptop (Windows Vista) keeps freezing and "not responding". iTunes appears to work okay when the phone is not connected.

  • Reverse Engineering a Model

    I am using SQL Data Modeller to reverse engineer an Oracle database to produce a diagram for a data model that was made a while back now. I created the diagram successfully and was very pleased with the results and the process. However, since creatin

  • Upgrade From SRSS 4.2 RTM to SRSS 5.2.3 - Is This Possible?

    Dear All, I'm planning an upgrade to SRSS 5.2.3 for my production servers (two x64 Solaris hosts in a FOG) from SRSS 4.2 RTM. Does anyone know whether I can do a straight upgrade to 5.2.3 or do I have to go to 5.2 first and then apply the 5.2.3 upgra

  • Recovery in a different Host

    Hi, I have a RMAN backup running in my production database with nocatalog and the backup is in Disk. I want to restore the backup in a different host(QA) by mounting the backup files in QA server and recover only two tablespaces. Can anyone tell me t