Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Vista

Adobe InDesign CS5 : Using Scripts - Exploring VBA

7/20/2012 9:36:12 AM
VBA, and its subset version VBScript, is Microsoft's technology for writing your own programs, both those that run in other programs (scripts) and those that run by themselves (custom applications). InDesign works with both VBA and VBScript. The Visual Basic language that underlies both VBA and VBScript is not meant for everyday computer users; knowledge of programming is very useful in taking advantage of this technology. Although based on the Basic language developed in the 1970s to help new users write their own programs, it has evolved a lot since then and is no longer so simple.

1. Learning the language

Many of the actions specified in VBA have some degree of English, such as:

set myTextFrame = InDesign.Documents.Item(1).Spreads.Item(1).
   TextFrames.Add

or

mySelection.RotationAngle = 30

As you can see, that degree of English is slight. The first code segment, for example, means to add a text frame to the first spread in the first document. The second means to rotate the selected object by 30 degrees.

2. What you need to write and run scripts

To use InDesign scripting in Windows, you need Microsoft Visual Basic or an application that contains VBA; these include Microsoft Office, Microsoft Visio, and AutoCAD. In Microsoft Office, you can run the Microsoft Script Editor by choosing Tools => Macro => Microsoft Script Editor, which lets you create scripts, edit them, test your code, and fix errors. Figure 1 shows the editor with a sample script. (Note that the script editor's dialog box has the self-important name Microsoft Development Environment rather than Microsoft Script Editor.)

Getting More Information on VBA

Before you venture too far into scripting, you should review the VBA-related information provided by Microsoft and with InDesign:

  • Microsoft scripting documentation and tools: Microsoft has a lot of information on VBA, VBScript, and Visual Basic on its Web site. Unfortunately, it's not well organized and thus is hard to find and understand. There's no tutorial that simply explains how a new scripter needs to get started. However, you can search on the Microsoft site for VBA, VBScript, and Visual Basic to get links to documents that may prove useful.

  • InDesign scripting documentation: The InDesign DVD contains a 2,000-plus-page PDF file that explains scripting in InDesign, including VBA programming. This document, although definitely on the technical side, is a valuable resource. It includes an overview of VBA scripting and the object model, as well as a list of InDesign-specific scripting terms and scripting examples.


Figure 1. The Microsoft Development Environment window contains sample VBA text. When you work on a script, the Microsoft Development Environment applies indents automatically.

You can also write scripts in VBScript, a VBA subset, in a text editor such as WordPad. You need Microsoft's free Windows Scripting Host (WSCRIPT.EXE), which is usually installed with Windows, and you can download it from Microsoft's Web site.

There's a third choice for your scriptwriting: You can also use the full Microsoft Visual Basic product.

NOTE

To use InDesign scripting in Windows, your user profile must have Administrator privileges.

To see what Visual Basic commands InDesign supports, you can view the InDesign object model — the supported commands — within the Microsoft's Visual Basic product; just choose Project => References and then select Adobe InDesign CS5 Type Library in the References dialog box and click OK.


2.1. Running your script

There are a few ways to run a VBScript. You can double-click the script in the Scripts panel within InDesign or double-click the script file itself from a folder. When developing scripts, you can run the script directly from the application in which you created a VBA or Visual Basic script, such as the Microsoft Script Editor. (VBScripts can be run from the Scripting Host application.) In all these cases, InDesign becomes the active program, and your script is running.

2.2. Saving your script

When you're finished writing and testing a script, choose Save from the script editor's File menu. Name your script and choose its storage location.

Other -----------------
- Dreamweaver CS5 : Standard Server Behaviors (part 6) - Stored procedure/command/callable
- Dreamweaver CS5 : Standard Server Behaviors (part 5) - Dynamic elements
- Dreamweaver CS5 : Standard Server Behaviors (part 4) - Update Record, Delete Record & User authentication
- Dreamweaver CS5 : Standard Server Behaviors (part 3) - Go To Detail Page, Related Page & Insert Record
- Dreamweaver CS5 : Standard Server Behaviors (part 2) - Recordset Paging, Move To Specific Record & Show Region
- Dreamweaver CS5 : Standard Server Behaviors (part 1) - Recordset & Repeat Region
- CorelDRAW X5 : Text and Styles
- CorelDRAW X5 : Wrapping Text Around Other Shapes
- Adobe Illustrator CS5 : Working with Layers - Flattening Layers & Locating Objects in the Layers Panel
- Adobe Illustrator CS5 : Working with Layers - Moving Objects to a Layer
 
 
Top 10 video Game
-   F1 2015 [PS4/XOne/PC] Features Trailer
-   Act of Aggression [PC] Pre-Order Trailer
-   Sword Coast Legends [PC] Campaign Creation E3 2015 Trailer
-   Sword Coast Legends [PC] Campaign Creation E3 2015 Dungeon Run Trailer
-   Naruto Shippuden: Ultimate Ninja Storm 4 Trailer
-   Danganronpa Another Episode: Ultra Despair Girls Trailer 2
-   Project X Zone 2 Trailer
-   Poly Bridge Early Access Trailer
-   Rodea The Sky Soldier Trailer
-   CABAL 2 Launch Trailer
-   The Smurfs Trailer
-   Act of Aggression Pre-Order Trailer
-   Project X Zone 2 [3DS] Trailer
-   Minecraft: Story Mode Debut Trailer
-   Minecraft: Story Mode Reveal Trailer at Minecon 2015
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 windows Phone 7 windows Phone 8
programming4us programming4us
 
Popular keywords
HOW TO Swimlane in Visio Visio sort key Pen and Touch Creating groups in Windows Server Raid in Windows Server Exchange 2010 maintenance Exchange server mail enabled groups Debugging Tools Collaborating
programming4us programming4us
PS4 game trailer XBox One game trailer
WiiU game trailer 3ds game trailer
Trailer game
 
programming4us
Natural Miscarriage
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Game Trailer