Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[JS CS3] Loading master pages from one ID file into another

Participant ,
Mar 07, 2008 Mar 07, 2008
I'm having trouble working this out...

I'm trying to create a script that will assume 1 document is open when the script is run. It will then create a new document, and load the master pages from the first document into the new document. I can't figure out how to reference the original document once the new document has been created. Here is what I have so far...

var oldDocument = app.activeDocument;
// Create a new document with the correct page size, etc.
var newDocument = app.documents.add();
newDocument.documentPreferences.pageWidth = 7.625;
newDocument.documentPreferences.pageHeight = 10;
// Load masters from old document
newDocument.loadMasters(app.documents.item(0).fullName);

The last line is not correct, obviously. How do I reference the first document while working on the second? Thx.
TOPICS
Scripting
599
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 07, 2008 Mar 07, 2008
It's still oldDocument:

newDocument.loadMasters(oldDocument);

Doesn't that work? I didn't actually realize there was a loadMasters method for documents!

Dave
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 07, 2008 Mar 07, 2008
var oldDocName = app.activeDocument.name;
// Create a new document with the correct page size, etc.
var newDocument = app.documents.add();
newDocument.documentPreferences.pageWidth = 7.625;
newDocument.documentPreferences.pageHeight = 10;
// Load masters from old document
newDocument.loadMasters(app.documents.item(oldDocName).fullName);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 07, 2008 Mar 07, 2008
Thanks Dave

http://www.kobimedya.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 10, 2008 Mar 10, 2008
newDocument.LoadMasters(oldDocument) doesn't work. I get the error "Invalid value for paramenter 'from' of event 'loadMasters'. Expected File, but received Document". So I guess loadMasters expects a reference to a file name.

The approach suggested by Kasyan works great. Thank you to you both, Dave and Kasyan!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 10, 2008 Mar 10, 2008
LATEST
Ah, in that case:

newDocument.LoadMasters(oldDocument.fullName)

would have done the trick.

Dave
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines