Article View: adobe.scripting.indesign
Article #16804My very first steps with VB, Please help
From: Richard Ronnback
Date: Wed, 30 Jul 2003 05:07
Date: Wed, 30 Jul 2003 05:07
84 lines
4208 bytes
4208 bytes
I know a little bit of AppleScript, but sometimes I just have to do somethings for Windows as well so I thought I should learn a bit of VB.
I have downloaded the Visual Basic Control Creation Edition and done the "Hello World" Examples of the InDesign Scripting Guide, so I thought that a useful way to take the next would be to port an AppleScript for exporting the pages of the active document as separate PDF's. Needless to say, I run into a number of specific challenges that I would really need some help to get through. The original AppleScript goes like this:
tell application "InDesign 2.0.2"
-- This section gets the info from the document
set myDocument to active document
set myName to name of myDocument
set myPages to pages of myDocument
set myFolderPath to (choose folder with prompt "Please select the folder you want to save your PDF pages in") as string
set myStyles to name of PDF export styles
set myExportStyle to (choose from list myStyles with prompt "Please Choose an Export style") as string
-- This part is used to get a special character in the file name
set mySeparator to "_"
--This is where things actually happens
repeat with anItem in myPages
set myPageNumber to name of anItem as string
set MyPDF to myFolderPath & myName & mySeparator & myPageNumber & ".pdf"
set page range of PDF export preferences to myPageNumber
tell myDocument
export format PDF type to MyPDF using myExportStyle without showing options
end tell
end repeat
end tell
I have tried to do the same in VB, but I have a number of questions (as well, probably, as some things I haven't yet noticed) Please help me understand these
Private Sub Command1_Click()
Dim myInDesign As InDesign.Application
Dim myDocument As InDesign.Document
Set myInDesign = CreateObject("InDesign.Application.2.0")
Set myDocument = myInDesign.ActiveDocument
Rem Set myName = myDocument.Name
Rem WHY DO I GET THE ERROR "Object Required"?
Set myPages = myDocument.Pages
set myFolderPath =
Rem HOW CAN I GET A DIALOG FOR SELECTING DESTINATION FOLDER?
Set myStyles = myInDesign.PDFExportStyles.Name
set myExportStyle =
Rem HOW DO I DISPLAY A LIST USERS CAN CHOOSE EXPORT STYLE FROM?
Set mySeparator = "_"
Rem THIS IS NOT HOW YOU SET A STRING IN VB, IS IT?
For Counter = myDocument.Pages
Rem HOW DO I MAKE A COUNTER FOR OBJECTS IN myPages ONLY?
set myPageNumber =
Rem HOW DO I REFER TO, AND GET THE NAME OF, THE CURRENT ITEM ONLY?
Set myPDF = myFolderPath & myName & mySeparator & myPageNumber & ".PDF"
Rem IS THIS REALLY HOW YOU CONCATENATE STRINGS AND VARIABLES IN VB?
myInDesign.PDFExportPreferences.PageRange = myPageNumber
Rem CAN I REALLY FEED THE PAGE RANGE WITH A VARIABLE?
myDocument.Export idExportPDF, myPDF, False, myExportStyle
Next Counter
End Sub
Also, I have some general questions:
* What is a good (simple) book for learning VB?
* What is the equivalent of the AppleScript Editor's Event Log?, i.e. how can I tell what is going on in my script, and get the results of, say setting a variable?
* I notice that I can't save my project as an *.exe-file, is that something I would need the full VisualBasic application for? If so, will I need to convert the project to a VBScript (text) file in order for someone else to run it?
Sorry for all the question and thanks in advance
Technical Details
Message-ID:
<1dea1f4d.-1@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,2fd3579b7029caa,start X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-07-29 22:37:36 PST From: "Richard Ronnback" <richard.ronnback@telia.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: My very first steps with VB, Please help Message-ID: <1dea1f4d.-1@WebX.la2eafNXanI> Date: Tue, 29 Jul 2003 22:07:45 -0700 Lines: 93 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit