17 Replies Latest reply on Apr 9, 2009 3:01 PM by Tony Tuneson

    Place INDD file, select page (CS3)

    Tony Tuneson Level 1
      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
        • 1. Re: Place INDD file, select page (CS3)
          Tony Tuneson Level 1
          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?
          • 2. Re: If CS3 does not accept a VB call
            Tony Tuneson Level 1

            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.

            • 3. Re: Place INDD file, select page (CS3)
              AdobeScripts Level 3

              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

              • 4. Re: Place INDD file, select page (CS3)
                Tony Tuneson Level 1

                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!

                • 5. Re: Place INDD file, select page (CS3)
                  AdobeScripts Level 3

                  can you post part of your code again ?

                   

                  robin

                  www.adobescripts.co.uk

                  • 6. Re: Place INDD file, select page (CS3)
                    Tony Tuneson Level 1

                    Hello Robert, the code below describes the problem.

                     

                    'in General Declarations Section
                    Option Explicit
                    Dim myInDi As InDesign.Application

                    Private Sub Form_Load()
                    'Startup Form
                        Set myInDi = CreateObject("InDesign.Application")
                       
                    'This line gives a Type Mismatch Error
                        myInDi.ImportedPageAttributes.PageNumber = 2
                       
                    'This line works fine
                        myInDi.DoScript "app.importedPageAttributes.pageNumber = 2", InDesign.idScriptLanguage.idVisualBasic

                      
                    End Sub

                    • 7. Re: Place INDD file, select page (CS3)
                      AdobeScripts Level 3

                      then try trashing your preferences - SHIFT+CTRL+ALT when InDesign start - sometimes scripts don't work if preferences are corrupted

                       

                      robin

                      www-adobescripts.com

                      • 8. Re: Place INDD file, select page (CS3)
                        Tony Tuneson Level 1

                        Okay, all my preferences are gone and the Script still works, while the direct VB6-call gives the Type Mismatch.

                        So: nothing changed...

                        • 9. Re: Place INDD file, select page (CS3)
                          Ildhund Level 3

                          Is it significant that importedPageAttributes is not the same as

                          ImportedPageAttributes?

                           

                          Noel

                          • 10. Re: Place INDD file, select page (CS3)
                            Tony Tuneson Level 1

                            In JavaScript it sure is. I don't think VB is case sensitive however.

                            Besides that: VB6 automatically makes it in Capitals. There is no way to pass it without Capitals. Also in the Object Browser and the "Auto-Suggest" (?) lists it using Capitals.

                            • 11. Re: Place INDD file, select page (CS3)
                              AdobeScripts Level 3

                              VB6 and VBScript are 100% case insensitive

                               

                              what if you run your script as VBScript - from InDesign Scripts palette as VBS - not from VB6 IDE or not as EXE ?

                               

                              robin

                              www.adobescripts.co.uk

                              • 12. Re: Place INDD file, select page (CS3)
                                Tony Tuneson Level 1

                                I don't expect problems with running it as a script, because the DoScript works as well, but I'll try (no time now).

                                I'll also try to compile first and run it as .exe. Maybe the IDE causes the problem.

                                Still I seem to be the only one with this problem - I don't like that idea!

                                Thanks for your suggestion.

                                • 13. Re: Place INDD file, select page (CS3)
                                  Tony Tuneson Level 1

                                  As expected:

                                   

                                  DoScript JS Call from VB IDE: OKAY

                                  DoScript VB Call from VB IDE: OKAY

                                  As VBS from Script Palette: OKAY

                                   

                                  Straight VB statement from VB6 IDE: Error 13 (Type mismatch)

                                  Straight VB statement from .exe: Error 13 (Type mismatch)

                                   

                                  Looks like it's a different API or DLL or something...?

                                  • 14. Re: Place INDD file, select page (CS3)
                                    AdobeScripts Level 3

                                    ok ... LAST thing - what EXACTLY version of InDesign do you have - 5.0.x ?

                                     

                                    robin

                                    www.adobescripts.eu

                                    • 15. Re: Place INDD file, select page (CS3)
                                      Tony Tuneson Level 1

                                      5.0.4

                                       

                                      It sounds as if you're taking this really serious! I hope to hear what you can find out.

                                      • 16. Re: Place INDD file, select page (CS3)
                                        AdobeScripts Level 3

                                        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]\AppDa ta\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

                                        • 17. Re: Place INDD file, select page (CS3)
                                          Tony Tuneson Level 1

                                          VISTA 32-bit

                                           

                                          Reference=*\G{B694A47E-004D-48E0-AE77-B37A9CC18760}#1.0#0#C:\ProgramData\Adobe\InDesign\Ve rsion 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.