[CS3][JS] Uniquely identifying documents with common names - possible?

Hi!
Is there no way to refer directly to a document in app.documents when there are several documents with the same name open at the same time (located in different folders)?
I have tried to assign unique labels to the documents when opening them, but have not succeeded in referring to documents by their labels, only by name - and the name not being unique, I get just one document reference (the first).
I also tried using the documents.itemByRange function, supposedly returning an array of all documents in the range defined by the parameters sent to the function. However, sending in the same name in the "from" and "to" parameters, returned only one document:
app.documents.itemByRange('test.indd', 'test.indd').getElements().length
Result: 1
//(I would have expected to get both of them)
// Referring directly by the name:
app.documents.item('test.indd').getElements().length
Result: 1
// Checking the name of the documents by their indexes:
app.documents.item(0).name
Result: test.indd
app.documents.item(1).name
Result: test.indd
Do you really have to loop through all open documents and check their fullName to be able to uniquely identify a document if the names are not unique?
Kind regards,
Andreas Jansson

Hi Dave,
Make that three or four... ;)
Kris at Rorohiko created a method to get unique references to two
different documents with the same name. It's usable if you have the free
APID ToolAssistant version 1.0.44 or higher. (it doesn't need to be
licensed...)
Here's an excerpt from the reference manual:
The get doc GUID function is used as follows:
guid =
app.callExtension(0x90B6C,10008,document);
This function returns a GUID (Globally Unique Identifier) for a
document. This is a string of the form
{nnnnnnnn-nnnn-nnnnnnnnnnnnnnnnnnnn}
where all 'n' stand for a hexadecimal digit.
These GUID allow you to work with same-name documents that
are concurrently open without getting tangled in the confusion
that occurs when using resolve calls.
As long as a document is not moved from its original location on
disk, it will keep the same GUID. Two documents with the same
name but different paths will have different GUID.
Opening, closing, (re)saving to the same location will NOT
change the GUID.
Moving a document to another location will change the GUID.
The find open doc by GUID function is used as follows:
doc = app.callExtension(0x90B6C,10009,guid);
This function retrieves a reference to an already open document
based on its GUID string.
These GUID strings are unique and persistent and allow
persistent references to same-name documents without resolvelike
issues (but the documents are meant to be 'unmovable' i.e.
they cannot be renamed or moved to another folder). Once the
document is open, it can be retrieved via its GUID.
HTH,
Harbs

Similar Messages

  • Error while uploading document with same name in Document library

    Hi,
    Whenever I try to upload document with same name in Document library it throws an error. I know its a default behavior but is there any way so that I can upload documents with same name or can we append some unique id with title of the document?
    Please suggest.
    Thanks

    No, unfortunately this is not possible. SharePoint treats the file name as the primary key identifier for a document so if you try to upload a second document with the same name it will assume this is a new version of the file. If you have versioning enabled
    on the document library, it will add this as a new version. If not, it will overwrite the original file with the new one.
    If you need two documents with the same name, you will have to either place them in different folders within a document library or in different document libraries.
    http://stackoverflow.com/questions/11894968/uploading-documents-with-same-name-to-sharepoint-2010
    Regards,
    Rajendra Singh
    If a post answers your question, please click Mark As Answer on that post and Vote as Helpful
    http://sharepointundefind.wordpress.com/

  • WORKAROUND: "A document with the name 'vnd.ms-excel' is already open"

    I'm posting this in the hope that it might help someone else (or that someone else might suggest a better solution)...
    I'm using the technique described in the Integrating Oracle Reports in Oracle Forms Services Applications white paper. Basically, this means using RUN_REPORT_OBJECT to generate a report, and then navigating to a URL of the form...
    http://<host>/reports/rwservlet/getjobid<n>?server=<name>...to show it.
    I had the requirement that some reports (with DESFORMAT=DELIMITEDDATA) needed to open in Excel, so for these reports I added the MIMETYPE command to the URL, so that it was of the form:
    http://<host>/reports/rwservlet/getjobid<n>?server=<name>&mimetype=application/vnd.ms-excelThis appeared to work, but only for one report at a time. I could generate one report this way, and when I navigated to its URL, the report would be displayed by Microsoft Excel within a new browser window as expected. However, if I left the browser window open, then generated a second report and navigated to its URL, a new, empty browser window was displayed, but a "Microsoft Excel" message box appeared with the following message:
    A document with the name 'vnd.ms-excel' is already open. You cannot open two documents with the same name, even if the documents are in different folders.
    To open the second document, either close the document that's currently open, or rename one of the documents.
    When I chose OK (the only button), the message box closed, but the new browser window remained empty.
    If Excel was already running to begin with, the message box was obscured behind other windows, and the new browser window remained empty and appeared to never finish loading (because it was waiting for a response from the message box). The message box only appeared if I explicitly navigated to Excel (for example, using the taskbar). When I chose OK, a "File Download" dialog appeared, followed by a message box that reported the following:
    Microsoft Excel for Windows has encountered a problem and needs to close. We are sorry for the inconvenience.
    When I closed this message box, Excel shut down.
    I could not find this documented anywhere, but it appears as if Excel interprets the text after the last "/" in the URL as the file name. In my case, this was the same text every time (specifically "vnd.ms-excel"), which caused problems because Excel does not allow you to open two files with the same name.
    My workaround was simply to add the "JOBNAME=/<n>" command (where <n> is the job ID) to make the text after the last "/" unique (at least in my case). In other words, by using a URL of the form...
    http://<host>/reports/rwservlet/getjobid<n>?server=<name>&mimetype=application/vnd.ms-excel&jobname=/<n>...I was able to avoid the problem. For example, for job ID 123, the URL would be...
    http://<host>/reports/rwservlet/getjobid123?server=<name>&mimetype=application/vnd.ms-excel&jobname=/123...and Excel would interpret the file name as "123".
    Hope this helps.

    Thanks for posting, this solution worked!

  • Minumum and Maximum pointsize in the active document with font name

    hi
    How to find the font with point size in active document and how to get the minimum point size and maximum point size used in the active document with font name
    Thanks in Advance.

    Okay, that does look good (without testing it). Does it do its job?
    I think it can be made a bit more efficiently by not running over all text frames, but rather over all stories in the document -- a small change, the rest can stay the same.
    You can also try turning the gathering of used data around. It appears you are now pushing every item immediately into your array, then weed out duplicates. (For my thoughts on the latter, see below!) It might be quicker and more memory-efficient to scan your present array to see if the new item is already in there, and only push when it's not. (Bonus points for a binary tree implementation -- the fastest possible way! But a linear search on the entire array, or on a sorted array and bailing out if you go "past" the current item, may be fast enough.)
    (On Weeding out duplicates; you might want to skip this, as it won't be necessary for the above:)
    Your function UniteSame sorts out and removes duplicates by comparing every item to every other one; then it sorts the array. An alternative can be to
    1. Sort the array
    2. Create a new empty one
    3. Push an item of the original onto the new one.
    4. Skip items of the original list while they are the same as the bottom one of the new list.
    5. Until you run out of items.

  • TextEdit: how save document with new name?

    I tryed in many ways to save modified document with new name with TextEdit but no one works for me.

    Use TextEdit > File > Duplicate.
    For this example, my original document is named Lorem.rtf. I open it with TextEdit, and then Duplicate it. A new TextEdit document window appears. Its default name is Untitled (Lorem copy). If you pass your pointer near the right parenthesis, a downward pointing triangle appears. Click that and the Name field has Lorem Copy preselected. Press the delete key to erase this name, and enter the new name — followed by a return to set it.

  • Link to Excel document in site throws "Document with same name already open"

    
    I have an Excel document stored in a document library in SP2010.  I provided a link to the document in a CEWP on a page.  When clicking the link on the page, Excel throws the erorr "Two documents with the same name cannot be opened" error. 
    When clicking the link in the document library, the Excel workbook opens fine.  When hovering over both links, the URL in the status bar is identical.  Here is the link in the page:
    <span style="width:120px; padding-right:50px;">
    <a class="ms-addnew" href="https://mydomain.com/sys/groups/ermcg/RA/Shared%20Documents/RA1.xlsm">
    <img src="https://mydomain.com/sys/groups/ermcg/RA/SiteAssets/excelsmall.jpg" style="border:none;vertical-align:middle;"></img>&nbsp;Download to Excel</a>
    </span>
    Thanks in advance,

    Hi jd_hancock,
    The scenario is not reproduced in my environment.
    I used Fiddler to check whether there are differences between them to download the file, it seems the same and the file also successfully opened in the Content Editor Web Part.
    I would suggest you to use the same way to check whether the download process is the same, also, type the url directly in the address bar, whether the document can be opened as expected?
    Thanks,
    Qiao
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Qiao Wei
    TechNet Community Support

  • Previews does not actually "replace" if document with same name is open.

    I am using FMP 9.0--When I "save records as PDF"....
    IF I have a pdf open in Preview with the same name,
    Preview offers to "save as",
    tells me I have one w/the same name and asks if I want to replace...
    I say YES....and
    ONLY the older version is saved.
    (I happen to be troubleshooting a script so the name is "toss.pdf"--several times. If the previous toss.pdf is not open it works as anticipated. Otherwise I do not actually "replace" the older one as preview leads me to believe.)
    I have not tried this on a non-intel machine, so I don't know if it's Intel specific--or if it's just me...:-).
    Not a huge problem, but it seems that if it is an issue it could use a fix..

    Hi,
    Thank you for posting in Windows Server Forum.
    By default it will automatically update the RemoteApp and Desktop Connections but if in any particular case it’s not happening then for a try you can restart the server and check the result again.  In addition you can try running below command and check
    the result. 
    Start-Process rundll32 -ArgumentList "tsworkspace,TaskUpdateWorkspaces2
    More information:
    Powershell to update "RemoteApp and Desktop Connections"
    If a task is registered using the Administrators group for the security context of the task, then you must also make sure the Run with highest privileges check box is checked if you want to run the task. Please check “Task
    Security Context” for more details.
    Hope it helps!
    Thanks,
    Dharmesh

  • Find and delete files with common name in different directories

    I have hundreds of invisible files in many different directories on my 10.4.11 server with .fstemp at the beginning of their name.
    They are taking up space and I would like to delete them.
    I can find them using
    find . -type f -name .fstemp
    But I can't work out how to use the rm command with a wildcard to delete them - I don't want to have to visit many different directories and run rm.
    Do I need to pipe the results from the find to rm ?
    For extra credit (you can probably tell I am out of my comfort zone here)... the files are all locked. I believe they will need to have
    chflags nouchg /Directory/filename
    applied to unlock them before they can be deleted. Can the terminal pipe find|chflgs|delete?
    Thanks,
    b.

    Well, if they weren't locked you could just 'delete' them in the find command. Otherwise …
    Open the Terminal (from /Applications/Utilities) and copy and paste the following into the Terminal window, one line at a time, with a return after each line:
    sudo -s
    find / -type f -name ".fstemp*" -exec echo 'chflags nouchg "{}" && rm -f "{}"' ; | sh
    I have tested this, but obviously with some substitutions. You only need the double quotes around the curly brackets, "{}", if your filenames contain a space.
    To be on the safe side, you should check this out without the final "| sh". Then you will see the commands that would be executed with the full version.
    Finally type exit to get out of the root shell.

  • Smart View/Excel A document with the name 'HsTBar.xla' is already open

    I got this error message when starting Excel. The following fixed it:
    1. Deleted shortcuts to HsTBar.xla in Documents and Setting
    2. Disabled Smart View in Hyperion > About
    3. Unchecked Hyperion Smart View for Office in Tools > Addins
    4. Quit Excel
    5. Started Excel
    6. Enable Smart View Hyperion > About
    I do not know exactly what fixed the problem as the error has not reoccured but hopefully this will help someone.

    Thanks for posting, this solution worked!

  • How do I save document with different name

    Since I updated my softwhere, can't seem to find how to "save as"....help!

    Hi Draomin,
    Your profile shows this:
    Draomin's Products
    iMac, Mac OS X (10.7.5)
    iPad, iOS 6.1
    Mac Book Pro 17", Mac OS X (10.4.6), 1 Gig/Manuf date of April 2006
    Mac Pro, Mac OS X (10.6.8)
    MacBook Pro, Mac OS X (10.7.5)
    If your profile is correct, then I surmise that you are using OSX Lion. "Save As" is not available in Lion.
    Your options:
    1. Upgrade to Mountain Lion. You will see that "Save As" is back. You will find "Save As" by holding down the option (alt) key when you use the File menu in Pages, Numbers, TextEdit and other apps under Mountain Lion.
    2. Stay with Lion and learn how to use "Duplicate". It is not hard.  See my replies to this thread:
    https://discussions.apple.com/message/21418250#21418250
    3. Stay with Lion and don't bother to learn how to use "Duplicate". Join the 38574 Views 1,085 Replies on what I call the Whinge Thread:
    https://discussions.apple.com/thread/3216589?start=0&tstart=0
    Your choice.
    Ian.

  • [JS CS3] Frontmost document/selection when other with same name?

    I have a few scripts used to perform various operations on the current selection in InDesign. Under normal circumstances these work fine, but I can't seem to reliably get the frontmost document/selection when there is another document open with the same name. Most references to the document and every reference to the selection I have tried so far will simply lead to the document which was most recently opened (and has the same name).
    app.activeDocument.fullName always return the path to the most recently opened document of the same name, but app.documents[0].fullName will return the correct path. Trying to get the selection though will always return the selection of the most recently opened document of the same name, regardless of whether I try app.selection, app.activeDocument.selection or app.documents[0].selection. I have also tried with getElements()[0] appended to the document reference but it makes no difference.
    My primary environment is still CS3 and the problem appears to be that it only references documents by name. Brief testing with CS5 indicates this has been solved by Adobe, presumably because it now refers to documents using an id by default. Haven't tried CS4 but since its document object does not have an id property I'd assume it will behave the same as CS3. Is there any way around this, or is the best I can do to detect the issue (a simple app.activeDocument != app.documents[0] comparison seems to work reliably) and refuse to run if encountered?

    Welll...chances are the selected item will not be a valid ID in both documents of the same name. (I don't think ID's are globally unique, so that's not a guarantee -- but it's something you can check and only give an error if it happens to be that there is a collison).
    So, get the transaction specifier of the selection:
    app.activeWindow.selection[0].toSpecifier()
    Result: /document[@name="u1.indd"]//text-frame[@id=211]
    Then, iterate over app.documents to find the indexes of the documents with that name.
    In my test, of course it is just zero and one.
    Then, try to resolve the specifiers against those documents:
    resolve("/document[0]//text-frame[@id=211]")
    Result: [object TextFrame]
    resolve("/document[1]//text-frame[@id=211]")
    Error: Object is invalid
    Since only doc 0 has a textFrame with id 211, you know it's doc 0 and you have a valid specifier.
    I chose to adjust the specifier by hand, because I think that's probably the most general. The other choice would be to call app.documents[0].textFrames.itemByID(211), but then you would need to map "text-frame" to "textFrames" and that seems annoying and errorprone.

  • Forced to save document with another new name?

    When I scan a document to a pdf, I open it and OCR the document.  It then tells me that I need to save the document with another name as the document is opened someplace else.  this is not true.  If I open a pdf and add a page to it, it tells me again that I need to save the document with a different name.  What is causing this problem?

    This cannot be done in Reader. Are you using Acrobat?

  • Understanding reference to a document vs its name

    I'm having a hard time understanding how reference to a document works, and where in the AppleScript reference it is explained.
    See this simple AppleScript:
    tell application "TextEdit"
      set MyDocument to make new document with properties {name:"Name1"}
              set text of MyDocument to "SomeText"
              set text of MyDocument to text of MyDocument & " with more text"
              set name of MyDocument to "Name2"
      -- display dialog ("" & name of MyDocument)  -- A: throws error
              set MyDocument to document "Name2"
      display dialog ("" & name of MyDocument) -- B: works fine
    end tell
    Should I remove the comments at the begining of the line where my comment A is, I would get an error from AppleScript like:
    "Can’t make name of document "Name1" of application "TextEdit" into type Unicode text"
    However, getting a new reference the "same" document using its new name allows me to display its name in a dialog.
    So, I understand that, somehow, when I get a reference to a document object, that reference becomes obsolete if I change its name, as if the name actually defines - to some extent - the uniqueness of the object (although TextEdit can have more than one document named "Name2" at the same time, as is shown by the result of running the above script a few times without window cleaning).
    I must say this behavior is somewhat a surprise to me, as I thought that, having a "pointer" to the object (I will avoid the term reference here), changing the value of a property of the object wouldn't render my pointer invalid.  But no; it seems as if my pointer/variable is re-evaluated when used, and that this evaluation is done using the name property as if it was its unique key.  Or is it something else?
    What I would like to know is:
    How do I know what are the properties that "uniquely" defines an object (and which, if I change them, will screw up the validity of my variables)?  Is the name property the only one, or are there other ones?  Whenever I see a name property in a class, should I understand it is a "unique key", or are there classes where the name property can be changed without making any of the above problem?
    How do I know which property is used by default to evaluate where a variable points to?
    Is there any way to make a variable point to such an object without risking to lose it even when an "unique key" property is modified?  I've played a bit with the "a reference to" operator with no success (although I might not have used it right).
    What part of the AppleScript reference explains this so my AppleScript-newbie/former-java-programmer brain can understand the logic behind this.  I kinda understand what's happening, though I'd like to clearly be explained why it works that way.
    Thanking in advance you, seasonned AP coders, for sharing your knowledge...

    1.
    The unique identifier of an applescript object can vary from object to object and application to application. Name and id are commonly used for unique identifiers, index is sometimes used, and some applications define their own odd unique referents. Plus, an object can have more than one unique identifier. In fact, you can objects with no public unique identifiers: e.g. 'word' objects, which can only be referenced by relative or absolute position in a string. See the discussions in applescript reference forms.
    So no, name properties are not always unique, though usually either the name or id property will be unique.
    2.
    As a rule, unique properties will be listed as read only (r/o) which means they can only be set at the time the object is made. Sometimes you have to hunt for them, though. For instance, document objects in Text Edit seem not to have any unique identifier until you notice that window objects have a unique id property and each window object has one and only one document object. So, you can uniquely specify a document using something like document of window id xxxxx.
    Note also that applescript can be annoyingly inconsistent. Sometimes you'll write a reference that looks correct and even compiles and it still won't work.  It depends on how thoroughly the developer fleshed out the core applescript routines.
    3.
    If you're going to change a unique property, step up to the object's container and find another unique reference that (temporarily) won't change. For example, if you want to change a file's name, find a reference to the file within its folder (e.g. third file of folder x). Of course, you can always kite it as you did above (change the name and then reference it as though it were a new object with the new name).
    4.
    read the object specifiers section of the applescript language guide; should get you oriented.

  • Upgrading from CS3 to CS5.  Issues with old file.

    I design a monthly publication, which is always started from a InDesign template.  This template was originally created in CS3 and all Incopy links were created using CS3 as well.
    We updated to CS5 today and now we are unable to log into those stories.  Here's the error message:
    "this story needs to be converted to "InCopy Document" format in order to edit it."
    Should I just unlink everything and create new InCopy Documents or is there a quick way to fix this?
    Thanks!

    I don't know, I think it's pretty quick.
    Open the file in CS3.
    Select all the stories in the Assignments panel (Shift-click to get them all). - 10 seconds
    Click the Unlink icon (trash can) at the bottom of the panel. - 1 second
    Close the file in CS3, doing a Save As w/another name if you want. - 5 seconds
    Open the CS3 file in CS5. Save it, or Save As. - 20-30 seconds (depends on how big)
    (Personally, at this point, even if I wasn't using InCopy, I would always export to IDML and then reopen it in ID CS5, saving the Untitled document with another name, since you're skipping a couple versions. But it's not necessary. If you do it, add another minute).
    Choose Edit > InCopy > Export All Stories, 10-20 seconds, depending on how many it has to export.
    The end. That's about 2 minutes, yes?
    AM

  • I created several pdfs & saved them in adobe acrobat pro.  I want to start all over & want to delete these pdfs so I am not confused with more than one document with similar titles.  How do I delete the document

    I am working on a big project & creating everything in word.  I then am turning the documents into PDF format so they will be easy for everyone to open.  I have several PDFs that are not the way I want them & want to delete them so I don't have so many documents with similar names.  Is there a way to delete a pdf from my saved document??  This is probably very simple & I am over thinking it, but appreciate any help.

    I was able to figure it out, & just as I thought way to simple!  UGH!

Maybe you are looking for