Copy link to clipboard
Copied
Hallo.
My intension is to open a document and save it at an other place (by choosing the path).
var myPath = new File (path);
var openFile = myPath.openDlg("Wähle die Datei aus");
var myNewBook = app.open(File(openFile));
var sv = File(myNewBook.name).saveDlg("Bitte Dokumentennamen eingeben.", ".indb");
if (sv != 0){
var doc = myNewBook.save(File(sv.path));
}
myNewBook.close(SaveOptions.YES);
This works until line 6. Then comes an error message like "you cannot save the dokument, it´s allready open".
A second question: where can I set a default saving-path (line 6)?
Greets!
Hi Peter.
Only five minutes ago I found the following solution:
var myPath = new File ("/path");
var openFile = myPath.openDlg("Wähle die Datei aus");
var myNewBook = app.open(File(openFile));
var sv = File(myNewBook.name.replace(myNewBook.name, newBookName)).saveDlg("Bitte Speicherort auswählen: " + newBookName,"INDB files: *.indb");
myNewBook.save(File(sv.fullName));
Thank you for your solution. Of course I´ll try that too.
Andreas
Copy link to clipboard
Copied
Instead of
var doc = myNewBook.save(File(sv));
use this:
var doc = myNewBook.save (sv);
saveDlg() returns a file object, and you should save a document using a full path name.
Another thing: you use this:
var sv = File(myNewBook.name).saveDlg(...)
and because you don't have a path name there, just a file name, saveDlg() targets the desktop by default. If that's what you want, fine. But otherwise use this:
var sv = File(myNewBook.fullName).saveDlg(...)
which is usually closer to where you want to go.
> where can I set a default saving-path (line 6)?
var sv = Folder('/d/test/').saveDlg("Bitte Dokumentennamen eingeben.", ".indb");
Peter
Copy link to clipboard
Copied
Hi Peter.
Only five minutes ago I found the following solution:
var myPath = new File ("/path");
var openFile = myPath.openDlg("Wähle die Datei aus");
var myNewBook = app.open(File(openFile));
var sv = File(myNewBook.name.replace(myNewBook.name, newBookName)).saveDlg("Bitte Speicherort auswählen: " + newBookName,"INDB files: *.indb");
myNewBook.save(File(sv.fullName));
Thank you for your solution. Of course I´ll try that too.
Andreas