11 Replies Latest reply on Mar 24, 2017 2:59 AM by anonym78990735

    InDesign 7.0 breaks Visual Basic reference

    partswiz Level 1

      I've previously posted this to the Indesign SDK & Scripting forums, but haven't gotten a reply.
      I thought I'd try again, rephrasing it a bit.
      When I installed Creative Suite 4, InDesign 6.0 installed a COM typelib for Visual Basic.
      C:\ProgramData\Adobe\InDesign\Version 6.0\en_US\Scripting Support\6.0\Resources for Visual Basic.tlb

      I am able to reference this from VB.NET Visual Studio 2010 and program against the InDesign scritping API like a charm - with full IntelliSense.

      With Creative Suite 5 InDesign 7.0 I am unable to establish this reference from Visual Studio.
      Visual Studio can't find the reference.

      Any ideas?

        • 1. Re: InDesign 7.0 breaks Visual Basic reference
          Harbs. Level 6

          One request is more than enough. If anyone has an answer for you, they will respond.


          Please DO NOT repeat your question in every thread on this (and other) forum(s). I'm deleting the duplicates.


          Thank you,



          (I don't know the answer to your question. Very few of us use .NET with InDesign. It's not officially supported...)

          • 2. Re: InDesign 7.0 breaks Visual Basic reference
            partswiz Level 1

            I reposted my request as replies to two specfic people who had respond knowledgably to similiar questions on older, similar threads. I was hoping as a result my question would reach them directly.  You're right, there's a paucity of knowledge about interactiing with Adobe products with Microsoft development tools.

            • 3. Re: InDesign 7.0 breaks Visual Basic reference
              cweger79 Level 1



              It is very true that Adobe seems very Microsoft-hostile when it comes to development tools. Which is curious, because they use Windows to develop stuff, so perhaps they're just Windows scripting hostile. My Windows developer friends (I'm mostly a Mac guy) laugh at me when I tell them I have to use COM technology to talk to InDesign, but that's just the way it is.


              In any event, CS5 installs a TLB file on my Win7 system here:


              C:\ProgramData\Adobe\InDesign\Version 7.0\en_US\Scripting Support\7.0\Resources for Visual Basic.tlb


              Unfortunately, if you try to add this as a reference to a VS2010 project, Visual Studio tells you that the reference could not be added.


              You can try what it says on page 13 of the InDesignCS5_ScriptingGuide_VB, which is this:


              Set myApp = CreateObject("InDesign.Application")
              Rem Publish the InDesign CS3 type library (version 5.0 DOM)


              This fails on my system unless I make the argument to CreateObject "InDesign.Application.CS5" and then it works. BUT, the TLB it creates is also not recognized by Visual Studio.


              I think this should be filed as a bug against CS5.


              Also note the comment in the code above that references CS3; it seems that Ole wasn't paying a lot of attention to Windows support when he was editing this document.


              So, bottom line, I think we're out of luck as far as having an object browser friendly listing of InDesign's scripting on Windows. However, it still works. For example, this code works:


                      Dim myApp As Object
                      myApp = CreateObject("InDesign.Application.CS5")
                      Dim myDoc As Object
                      myDoc = myApp.documents.add()


              You sacrifice quite a lot in Intellisense and debugging by not having the object model around, but you can still drive InDesign.


              Hope this helps.



              • 4. Re: InDesign 7.0 breaks Visual Basic reference
                cweger79 Level 1

                I found the solution, thanks to a suggestion in this post:




                Launch InDesign by right-clicking and choosing "Run as Administrator" (I assume you're on Windows 7, don't know if this trick works on earlier versions).


                This allows InDesign to make appropriate changes to the registry and who knows what else in the system.


                You can then quit InDesign and launch it normally (I don't like running things as Admin as a rule).


                After this, as if by magic, the "Adobe InDesign CS5 Type Library" appears in the COM tab in Visual Studio's "Add Reference" dialog. You can add it to your project and then, as the Guardian of Forever says on Star Trek, "All Is As It Was."


                Hope this helps.




                EDIT: forgot to mention that BEFORE you run InDesign as admin, you need to go to this directory:


                C:\ProgramData\Adobe\InDesign\Version 7.0\en_US\Scripting Support\7.0


                And DELETE (or rename) the file "Resources for Visual Basic.tlb"


                Otherwise this file doesn't get regenerated, and you can wind up with bad COM information. In my case, it resulted in errors like this (from VS C# 2010):


                "Unable to cast COM object of type 'System.__ComObject' to interface type 'InDesign.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{ABD4CBB2-0CFE-11D1-801D-0060B03C02E4}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."


                The best thing about Windows is how much fun you can have exploring while you're supposed to be actually doing work.


                Message was edited by: cweger79

                • 5. Re: InDesign 7.0 breaks Visual Basic reference
                  ITbyAinsworth Level 1

                  Yes, I love that about Windows too.


                  Thanks, John,  for the quick reply. (Especially on a holiday!)  I tried deleting the tlb (from both locations:  \users\mark\appdata\local\adobe\inDesign\version 7.5\en_US\Caches\Scripting Supoort\7.5\  AND c:\ProgramData\Adobe\InDesign\Version 7.5\en_US\Scripting Support\7.5. In Design restores both of these files (and they both show up in the reference browser), but I get the same message.  I tried using VS10 and Got a little more description:


                  Retrieving the COM class factory for component with CLSID {296CAEB5-C99C-4B3E-9359-6E7D6EAE71FC} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

                  • 6. Re: InDesign 7.0 breaks Visual Basic reference
                    WernerPerplies Level 1

                    You can fix it using regtlibv12.exe.


                    regtlibv12.exe is part of Net Framework.


                    copy this program to

                    Adobe->Indesign-Version X.0 -> de_DE -> Scripting Support -> X.0
                    (e. g..: C:\ProgramData\Adobe\InDesign\Version 7.0\de_DE\Scripting Support\7.0)




                    Open Command-window as Administrator

                    select systemdrive:

                    cd systemdrive:\ProgramData\Adobe\InDesign\Version 7.0\de_DE\Scripting Support\7.0 [return]

                    regtlibv12.exe "Resources for Visual Basic.tlb" [RETURN]

                    close command window






                    Or, using my tool:



                    but it exist only a German version:


                    Install an start,

                    -> Datei (file)

                    RegisterTypeLibForUser->search your tlb, Öffnen (open), that should fix it.

                    • 7. Re: InDesign 7.0 breaks Visual Basic reference
                      ITbyAinsworth Level 1

                      I found the answer to the 80040154 exception sort of by accident:  I was expecting the instantiation of the InDesign.Application object to start the application, as happens with some other Interop programs (notably Word and Excel).  Not so with this one.  You need to start the application before instantiating InDesign.Application.  You can do this using Diagnostics.Process.Start


                      (Example:  System.Diagnostics.Process.Start("C:\Program Files\Adobe\Adobe InDesign CS5.5\InDesign.exe")


                      Note:  You can execute the statement unconditionally since if InDesign is allready running InDesign will silently decline to create another instance.

                      • 8. Re: InDesign 7.0 breaks Visual Basic reference
                        partswiz Level 1


                        I have no trouble using this VB.NET code pattern in Visual Studio 2010 to instatiate InDesign.CS4 (6.0.6).  But with InDesign.CS5 the reference returned by CreateObject() generates a runtime error.  Has anyone encountered this?



                        Len Russell

                        Principal Developer

                        Case Parts Company




                        Public Class Form1


                        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

                                Dim app As InDesign.Application

                                Dim docs As InDesign.Documents


                                app = CreateObject("InDesign.Application.CS5")

                                docs = app.Documents

                            End Sub

                        End Class


                        InvalidCastException was unhandled

                        Unable to cast COM object of type 'System.__ComObject' to interface type

                        'InDesign.Application'. This operation failed because the QueryInterface call

                        on the COM component for the interface with IID '{ABD4CBB2-0CFE-11D1-801D-0060B03C02E4}'

                        failed due to the following error:

                        No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

                        • 9. Re: InDesign 7.0 breaks Visual Basic reference
                          jpatescwp Level 1

                          I successfully use this code in C# 4.0 (after importing the tlb file as InDesign)


                          using  System;//System.Activator,System.Type


                          Type inDesignAppType = Type.GetTypeFromProgID("InDesign.Application.CS5.5")??Type.GetTypeFromProgID("InDesign.Ap plication.CS4");

                          InDesign.Application _app = (InDesign.Application)Activator.CreateInstance(inDesignAppType);


                          This works without running regtlib* as it doesn't rely on the CLSID


                          PS: regtypelibv12.exe lives in C:\Windows\Microsoft.NET\Framework\v4.0.30319 (on my machine)

                          PSS: regtypelib did not fix my class not registered issue with delphi

                          PSSS: the cs5.5 tlb has the WRONG CLSID! it registers with windows using {11B39EA8-97C0-48B6-8BD2-4AA6632F8D9E} (not {296CAEB5-C99C-4B3E-9359-6E7D6EAE71FC} which was imported from the tlb)

                          changing the CLSID in the imported file corrected this problem for me in delphi (which uses CreateComObject(CLSID) to create the com server) (i've reported the bug via the https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform)

                          PSSSS: you /could/ call CLSIDFromProgID() to get the correct CLSID if you are working with win32

                          • 10. Re: InDesign 7.0 breaks Visual Basic reference
                            DANY2000 Level 1

                            Man. I don't know you but I love you. I've been fighting Indesign CS5.5 until I've found this post. Thanks a lot.

                            • 11. Re: InDesign 7.0 breaks Visual Basic reference
                              anonym78990735 Level 1

                              Old thread but save my life. I've been fighting with Indesign CS6 and Visual Studio 2015 for some time and thanks solution provided by jpatescwp I can run Indesign CS6 from Visual Basic. My code to run it is:


                              Dim myIndesignType As Type = Type.GetTypeFromProgID("Indesign.Application.CS6")

                              Dim myIndesign As InDesign.Application = Activator.CreateInstance(myIndesignType)


                              Thank You so much for sharing Your solution.