Copy link to clipboard
Copied
I need to make document copy to perform some operations on it.
Main problem, when I use Document.saveAs() is that I loose my original filename.
Is there any way to saving copy of existing document with modifying original filename?
That is unfortunate. Have you tried the action? Dynamic actions solve many problems.
Copy link to clipboard
Copied
* ...without modifying original filename
Copy link to clipboard
Copied
how are you losing your original file name?
SaveAs(File) takes a file as argument 1, you provide the file name and location.
Copy link to clipboard
Copied
Yes. but this name will be used as default filename for future file saving.
I want to save copy, and original file name should be left unchanged.
Copy link to clipboard
Copied
so you want to "save as" the current document, but you want it to save with the same name as the original document without overwriting the original file???
Copy link to clipboard
Copied
No, i want to save with different name, but I want to keep original document name unchanged.
Main goal is that I need to make some work on document copy without making any changes to the opened window with the original document.
I already solved this by doing export to screen whole document as PDF.
Copy link to clipboard
Copied
nevermind. i think i know what you're asking.
you can save the current file name as a variable so you can still access it later... then at any point you can perform another save as and use the saved file name in your File() argument.
Copy link to clipboard
Copied
This is not safe because opened document can has unsaved changes and user don't want to save these changes.
I described in the previous message how I solved this.
Copy link to clipboard
Copied
you can use a script save the current document, save the name to a variable, save as (which makes a copy and doesnt alter the current document) then make whatever changes you want.
you can always re-open the original document with app.open(File(fileNameVariable));
per your previous comment about wanting to keep the original file name unchanged.... you can't do that with save as... saveAs only saves the current document with a new file name. there is no method for duplicating a document in the way you're asking... except to save the current document, save as to make a copy, then reopen the original document. or i guess you could use a script to duplicate everything to a new document and leave the original completely untouched.
Copy link to clipboard
Copied
in the UI, you can use File > Save a Copy
this will save a new copy of the current document without altering the current document's name or saved status. but the duplicate file would need to be manually opened after that
Copy link to clipboard
Copied
Is it correct to mean that the problem is that when you do saveAs, the reference to the document is taken to the one you exported?
The solution to this problem is as follows.
Copy link to clipboard
Copied
Yes, this is exact problem.
but I can't duplicate file, because I'm calling JSX from the CEP panel and file i already opened.
Only ome way I found is to use export for screens call.
Copy link to clipboard
Copied
That is unfortunate. Have you tried the action? Dynamic actions solve many problems.