VBScript - Select all objects
Copy link to clipboard
Copied
Hi everybody,
I am looking for the syntax to select all objects of an InDesign document in VBScript.
I guess I have to use "idSelectAll.idAll" or something like "myInDesign.idSelectAll.idAll = 1634495520", but I can't find the proper way to put it.
I also tried to use the menu action [Set myMenuAction = myInDesign.MenuActions.Item("$ID/Edit.SelectAll") followd by myMenuAction.Invoke] but there is an error too.
I'm quite new in VBScripting. I went through a lot of reference material now but I still need some help!
Many thanks in advance.
Eliane
Copy link to clipboard
Copied
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application.CS3")
myInDesign.Select 1634495520
rem or alternatively
myInDesign.Select idSelectAll.idAll
Copy link to clipboard
Copied
Kasyan Servetsky wrote:
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application.CS3")
myInDesign.Select 1634495520rem or alternatively
myInDesign.Select idSelectAll.idAll
but I think Eliane want to select ALL objects from entire document
what is impossible - only objects on same spread could be selected at once
so ... as workaround - for small and simple/uncomplicated documents all pages could be combined as one spread
robin
--
www.adobescripts.co.uk
Copy link to clipboard
Copied
Oops! I just overlook that.
Copy link to clipboard
Copied
When I posted this question I wanted to find something to select all objects of... I didn't specify. But, yes, Robin, you're right! I will have to take this into account. In fact, I'm working with layers... So now, I have to continue searching to find the better solution!
Thanks for you help and comments!
Eliane
Copy link to clipboard
Copied
Well, "myInDesign.Select 1634495520" works!!!! but not your alternative solution.
"Dim myInDesign As InDesign.Application" is not accepted neither (Robin, which is another point concerning the differences between VBS and VB6), but the point is that I have the solution to my first problem. I can now continue.
Solution:
'Select all objects
Set myInDesign = CreateObject("InDesign.Application.CS3")
myInDesign.Select 1634495520
Many thanks!
Copy link to clipboard
Copied
Eliane_Yanou wrote:
Well, "myInDesign.Select 1634495520" works!!!! but not your alternative solution.
"Dim myInDesign As InDesign.Application" is not accepted neither (Robin, which is another point concerning the differences between VBS and VB6), but the point is that I have the solution to my first problem. I can now continue.
Solution:
'Select all objects
Set myInDesign = CreateObject("InDesign.Application.CS3")
myInDesign.Select 1634495520Many thanks!
because if you want to write
Dim myInDesign As InDesign.Application
or
myInDesign.Select idSelectAll.idAll
in VB6 IDE - you need to make reference to TLB file with info about functions, properties and enums available from "controlled" application - when you run VBScript from InDesign - you have already correct TLB file loaded
robin
www.adobescripts.co.uk
Copy link to clipboard
Copied
Great! I again learned something which I didn't understand till now!
Eliane

Copy link to clipboard
Copied
Just a note: if you're going to use Dim, make sure that you comment out the line before deploying your application. It *will* cause problems if you don't.
But a better question is--why do you need to select the objects? It's possible to work with the objects without selecting them, which gives you a way to do things with all objects on all pages (something you can't do using selection).
Thanks,
Ole
Copy link to clipboard
Copied
because she want to copy objects from specified layer from one document to another
robin
www.adobescripts.com

Copy link to clipboard
Copied
Hi Robin,
Understood, but you don't need to select or copy the objects to move them from one document to another.
[I'm still getting used to this new forum software--I've lost my ability to edit posts, and it somehow thinks I've only posted twice since November!:-)]
Thanks,
Ole

Copy link to clipboard
Copied
Here's a simple example that shows how to move a page item from one document to another using Duplicate():
Set myInDesign = CreateObject("InDesign.Application.CS4")
Set myDocumentA = myInDesign.Documents.Add
Rem Run this script from the Scripts panel in InDesign,
Rem or you will need to provide the decimal equivalents
Rem for the enumerations int he following lines.
myDocumentA.ViewPreferences.HorizontalMeasurementUnits = idMeasurementUnits.idPoints
myDocumentA.ViewPreferences.VerticalMeasurementUnits = idMeasurementUnits.idPoints
Set myLayer = myDocumentA.Layers.Add
myLayer.Name = "TargetLayer"
Set myRectangle = myDocumentA.Pages.Item(1).Rectangles.Add
myRectangle.GeometricBounds = Array(72, 72, 144, 144)
myRectangle.ItemLayer = myLayer
Set myDocumentB = myInDesign.Documents.Add
myRectangle.Duplicate(myDocumentB.Pages.Item(1))
No selection, no copying.
Thanks,
Ole
Copy link to clipboard
Copied
yes ... but we are talking about copying many objects at once not one by one
and in another thread - answer to this "problem" - http://forums.adobe.com/message/1877545#1877545
robin
www.adobescripts.com

Copy link to clipboard
Copied
Hi Robin,
Well, for whatever it's worth, I would still use duplicate, and then reestablish the text frame links after that. In my opinion, copy/paste should be reserved for cases in which there is literally *no other way* to do something.
Thanks,
Ole
Copy link to clipboard
Copied
Check out this script: http://www.hilfdirselbst.ch/foren/Ebenen_aus_einem_vorhandenen_Dokument_in_ein_neues_Dokument_import...
CopyFromOneDoc2Another_LayerSensitiveWithDocSelection.jsx
It’s in JS, but may be it already does what you need.
Kasyan

