Skip to main content
Inspiring
April 2, 2009
Question

Place INDD file, select page (CS3)

  • April 2, 2009
  • 3 replies
  • 2650 views
Can anyone please help with placing e.g. page 2 of an INDD file (preferrably in VB)? The imported file defaults to page 1; how can I tell to place page 2, or change the pagenumber after placing?
It would be nice to control the layers as well, but I hope I can figure that out myself once I can access the object.
I now place the INDD-file in a Rectangle. Is that maybe the problem for the error below? I'm completely stuck.
Did I miss a reference or tutorial on this?

Dim myImportedPage As indesign.ImportedPage
If Typename(myRect.AllGraphics.Item(1)) = "ImportedPage" then
Set myImportedPage = myRect.AllGraphics.Item(1) 'Error: Type Mismatch
end if
This topic has been closed for replies.

3 replies

Robert at ID-Tasker
Legend
April 9, 2009

ok - I'll answer to original post - because this "new improved forum" make more and more tight frames ... why editor can be wide - but forum not ??

ok - few more questions:

0) all other scripts works fine ?

1) what OS - XP, Vista ?

2) 32bit or 64bit ?

3) can you check in body of your project file - *.VBP - if you have line like this:

Reference=*\G{666F676B-7790-4B6F-B691-EC43C6F94C18}#1.0#0#..\..\..\Users\[user_name]\AppData\Local\Adobe\InDesign\Version 5.0\Caches\Scripting Support\5.0\Resources for Visual Basic.tlb#Adobe InDesign CS3 Type Library

instead of "..\..\..\Users\[user_name]\AppData\Local\" there could be "..\..\..\ProgramData\"

and could you please check one more thing - add new user to your computer and run your script again from this new user ?

robin

www.adobescripts.com

Inspiring
April 9, 2009

VISTA 32-bit

Reference=*\G{B694A47E-004D-48E0-AE77-B37A9CC18760}#1.0#0#C:\ProgramData\Adobe\InDesign\Version 5.0\Scripting Support\5.0\Resources for Visual Basic.tlb#Adobe InDesign CS3 Type Library

No "cache", however.

I tried the AppData version also (the first thing I suspected), it made no difference.

I'm remote desktopping right now and it's getting late. I'd rather not create new users with my sleepy head. I'll try that one of these days.

I can also try to run both apps as admin. Somehow I don't think that will help.

Over the years I have built a small library of VB-apps, but I had never ever had to make a workaround via a DoScript.

But now that you ask whether everything else works: there is one other thing that annoys me but doubt if it's related: if I assign myDoc.AllGraphics.Item(1) to myGraphic, it looks like it loses methods/properties that I can acces with AllGraphics.Item(1). Messages like "Unknown property". I'll have to dig into it for a good report, sorry.

My workaround is that I use the assigned myGraphic temporarily in the IDE to list the right syntax and then copy it behind AllGraphics.Item(1) to make it work...

I'm not a full time scripter or programmer. Maybe I'm overlooking something obvious. But I can make another thread of that some day, who knows.

It's midnight I'm going upstairs. Have a nice weekend.

Robert at ID-Tasker
Legend
April 9, 2009

pure VB6 code:

Option Explicit

Dim myInDi As InDesign.Application
Dim myDoc As InDesign.Document

Private Sub Form_Load()
    Set myInDi = CreateObject("InDesign.Application")
    Set myDoc = myInDi.ActiveDocument
   
    myInDi.ImportedPageAttributes.PageNumber = 2
    Call myDoc.Pages.Item(1). _

            Place("d:\robinet\test_file_CS3.indd")
   
    myDoc.AllGraphics.Item(1). _

            GraphicLayerOptions.GraphicLayers.Item(3). _

            CurrentVisibility = False
End Sub

works fine without any errors - 3rd layer in 2nd page test file after importing is set to invisible

robin

--

www.adobescripts.co.uk

Inspiring
April 9, 2009

Thanks for trying, Robert. I copied your code in a new project (although it is the same as what I had), and get the same Type Mismatch at

myInDi.ImportedPageAttributes.PageNumber = 2

DoScripting the line as follows works fine, even in VBScript... which is a mystery to me:

myInDi.DoScript "app.ImportedPageAttributes.PageNumber = 2", InDesign.idScriptLanguage.idVisualBasic

If anyone has an idea how to solve this mystery, be welcome to suggest!

Robert at ID-Tasker
Legend
April 9, 2009

can you post part of your code again ?

robin

www.adobescripts.co.uk

Inspiring
April 2, 2009
In addition: if I, prior to placing the INDD doc, say:

myIndesign.ImportedPageAttributes.PageNumber = 2

then I get a Type Mismatch as well; I tried an Integer, Long and Variant. Please help?
Inspiring
April 7, 2009

It's become clear that my InDesign CS3 simply does not accept the command "myInDesign.ImportedPageAttributes.PageNumber = 2" directly from my VB6. Maybe a bug or something strange on my machine. jongware suggested a workaround: passing the instruction as JavaScript as follows:

Pagenumber = 2

app.DoScript "app.importedPageAttributes.pageNumber = " + CStr(PageNumber), idJavascript

(VB-people: note the case-sensitivity, see the JS object browser for correct use of capitals!)

Teus, thanks a million! Maybe obvious to you, a time-saver for me.

If someone finds out that there is a better cure for this strange behaviour, I hope I'll hear it someday.