5 Replies Latest reply on May 14, 2009 4:18 AM by hiling

    InDesign server using VB Dot Net

      Hi,

      I need help regarding using InDesign server using Visual Basic .Net.
      I tried to generate a new document in the following ways:

      Dim IdApp As InDesign.Application
      Dim Doc As InDesign.Document
      Dim DocP As InDesign.DocumentPreset


      IdApp = CreateObject("InDesignServer.Application.CS3")

      ' This is the command that appears in the documentation:
      ' Adobe Indesign CS Scripting guide, page 11
      'Doc = IdApp.Documents.Add
      ' The Result:
      ' Compiles but generates the following run time error:
      'An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
      'Additional information: Invalid value for parameter 'DocumentPreset' of event 'Add'. Expected DocumentPreset, but received TRUE.
      ' In the following command I pass the parameters
      ' from the correct type in the correct order.
      ' The runtime result is as if the DocumentPreset
      ' parameter is the first and not the second
      Doc = IdApp.Documents.Add(False, DocP)
      ' The Result:
      'An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
      'Additional information: Invalid value for parameter 'DocumentPreset' of event 'Add'. Expected DocumentPreset, but received FALSE.
      ' I tried passing the parameters in reverse order
      Doc = IdApp.Documents.Add(DocP, False)
      ' Result
      ' Compile error:
      ' error BC30311: Value of type 'InDesign.DocumentPreset' cannot be converted to 'Boolean'.

      Besides these methods, I saw at the InDesign Java documentation that in non-scripting languages, as Visual Basic
      parameters cannot be omitted.
      At Java, the class OptArg is provided in order to supply such parameters.
      I couldn't find the corresponding class for Visual Basic.

      Thanks in advance for your help,
      C
        • 1. Re: InDesign server using VB Dot Net
          Level 1
          Hi C,

          Turn off Option Explicit and Option Strict and don't use Dim. The supported member of the VB family is VBScript, so you should make your VB.NET project as much like VBScript as possible. If you do this, you can omit parameters in VB.NET.

          Thanks,

          Ole
          • 2. Re: InDesign server using VB Dot Net
            Hi Cto,

            are you aware that you wont be able to use more than one InDesign Server instaace on one machin if you use CreateObject("InDesignServer.Application.CS3")?

            I do not know any possibility to specify the port.

            Joachim
            • 3. Re: InDesign server using VB Dot Net
              If you want to run a vbscript to IDS through a port, you can use it like javascript. Through SOAP. Javascript has a doscript() function to run vbscripts.
              • 4. Re: InDesign server using VB Dot Net
                Level 1
                You can access the InDesign Server COM object from Visual Basic in one of the following ways:

                * CreateObject This points to a running instance of InDesign Server if it can find one; otherwise, it instantiates an instance of InDesign Server and points to the new instance. Example:
                Dim idsApp As Object
                idsApp = CreateObject("InDesignServer.Application.CS3")

                * GetObject("name_of_configuration") This will attempt to point to the instance of InDesign Server that was started up with the corresponding "-configuration" param. If this instance does not
                exist, an exception is thrown with the error: Cannot create ActiveX component. Example:
                Dim idsApp As Object
                idsApp = GetObject("hi")

                * GetObject("configuration_portNum") This will try to point to the instance of InDesign Server that was started up with the corresponding -port param. If this instance does not exist, an exception is thrown with the error: Cannot create ActiveX component. Example:
                Dim idsApp As Object
                idsApp = GetObject("configuration_12345")

                NOTE:
                InDesign CS3 Server with MA updates applied is required in order to use GetObject() to target a specific instance of IDS. Also, you must run your VB application on the local system. IDS does not support targeting a specific instance of InDesign Server when running under IIS. Under IIS, you'll have to stick with the CreateObject() method.
                • 5. Re: InDesign server using VB Dot Net
                  hiling

                  Hi..

                  This is probably a stupid question, but what are the MA updates that you are referrencing to ? The GetObject()-method doesn't work for me, so I probably need that update...