Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Newbie: Using a com object in VC 7.1

Newbie: Using a com object in VC 7.1

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++comjavajavascript
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ebruinsma
    wrote on last edited by
    #1

    Hello, After trying to figure this out for days, and getting more and more frustrated, I decided that I need some help with my problem. My problem is this, I'm rying to create a webservice that allows me to run Java scripts in an Adobe InDesign instance. I've got sample code of how someone else created it in Visual Basic, but I've only got visual c++ v7.1:( (bought it for an InDesign plugin Project, wich we're not going to do because it's just to complicated, and the Javascript seems to be enough for our needs) Seeing that the only code that he needed to insert himself is about 8 lines, and the rest was automaticly generated by starting a new webservice project, I foolishly thought that it shouldn't be that hard to recreate that functionality into c++. Creating the webservice was that easy indeed, you even got a "hello world" without even coding a single line:). The VB I want to recreate is: Public Function DoScript(ByVal script As String) As String Try Dim ind As InDesign.Application ind = CreateObject("InDesign.Application.CS2", "localhost") Dim x As String = ind.DoScript(script, InDesign.idScriptLanguage.idJavascript) Return x Catch ex As Exception Return "An error occurred: " & ex.Message End Try End Function I found this article on this site and used it as a lead. http://www.codeproject.com/Purgatory/Adobe_InDesign_COM_object.asp[^] So I started by adding a reference to the InDesign com object to my project, and as far as I can see that was succesful. But when I want to compile the following code, I get the following error message: #include "stdafx.h" #include "InDesignCS2Class.h" #include "Global.asax.h" //using namespace Interop::InDesign; namespace InDesignCS2 { String* InDesignCS2Class::RunScript(String* script) { // create an InDesign instance InDesign.Application app = (InDesign.Application) COMCreateObject("InDesign.Application"); // get a reference to the current active document //InDesign.Document doc = app.ActiveDocument; // get the first page //InDesign.Page page = (InDesign.Page) doc.Pages[1]; //1e pagina // get the first textframe //InDesign.TextFrame frame = (InDesign.Tex

    C 1 Reply Last reply
    0
    • E ebruinsma

      Hello, After trying to figure this out for days, and getting more and more frustrated, I decided that I need some help with my problem. My problem is this, I'm rying to create a webservice that allows me to run Java scripts in an Adobe InDesign instance. I've got sample code of how someone else created it in Visual Basic, but I've only got visual c++ v7.1:( (bought it for an InDesign plugin Project, wich we're not going to do because it's just to complicated, and the Javascript seems to be enough for our needs) Seeing that the only code that he needed to insert himself is about 8 lines, and the rest was automaticly generated by starting a new webservice project, I foolishly thought that it shouldn't be that hard to recreate that functionality into c++. Creating the webservice was that easy indeed, you even got a "hello world" without even coding a single line:). The VB I want to recreate is: Public Function DoScript(ByVal script As String) As String Try Dim ind As InDesign.Application ind = CreateObject("InDesign.Application.CS2", "localhost") Dim x As String = ind.DoScript(script, InDesign.idScriptLanguage.idJavascript) Return x Catch ex As Exception Return "An error occurred: " & ex.Message End Try End Function I found this article on this site and used it as a lead. http://www.codeproject.com/Purgatory/Adobe_InDesign_COM_object.asp[^] So I started by adding a reference to the InDesign com object to my project, and as far as I can see that was succesful. But when I want to compile the following code, I get the following error message: #include "stdafx.h" #include "InDesignCS2Class.h" #include "Global.asax.h" //using namespace Interop::InDesign; namespace InDesignCS2 { String* InDesignCS2Class::RunScript(String* script) { // create an InDesign instance InDesign.Application app = (InDesign.Application) COMCreateObject("InDesign.Application"); // get a reference to the current active document //InDesign.Document doc = app.ActiveDocument; // get the first page //InDesign.Page page = (InDesign.Page) doc.Pages[1]; //1e pagina // get the first textframe //InDesign.TextFrame frame = (InDesign.Tex

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      You are working in C++ right ? The code of the article is for managed (I suppose because I'm not familiar with the syntax). Or at least, this isn't C++. That's why you get errors.

      E 1 Reply Last reply
      0
      • C Cedric Moonen

        You are working in C++ right ? The code of the article is for managed (I suppose because I'm not familiar with the syntax). Or at least, this isn't C++. That's why you get errors.

        E Offline
        E Offline
        ebruinsma
        wrote on last edited by
        #3

        Hi Cedric, Yes, I'm working in Microsoft Visual C++ .NET version 2003 Standard. That will be the problem then, but can you tell me what is the correct way to use a/the InDesign com object, because I'm completely lost. Erik

        T 1 Reply Last reply
        0
        • E ebruinsma

          Hi Cedric, Yes, I'm working in Microsoft Visual C++ .NET version 2003 Standard. That will be the problem then, but can you tell me what is the correct way to use a/the InDesign com object, because I'm completely lost. Erik

          T Offline
          T Offline
          toxcct
          wrote on last edited by
          #4

          ebruinsma wrote:

          I'm working in Microsoft Visual C++ .NET version 2003 Standard.

          this doesn't mean in which language you code (i leave in france, but could be speaking english, german or chinese). Cedric's question is : "do you program in Native C++, Managed C++, C#, VB.NET..." ?


          TOXCCT >>> GEII power

          [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

          E 1 Reply Last reply
          0
          • T toxcct

            ebruinsma wrote:

            I'm working in Microsoft Visual C++ .NET version 2003 Standard.

            this doesn't mean in which language you code (i leave in france, but could be speaking english, german or chinese). Cedric's question is : "do you program in Native C++, Managed C++, C#, VB.NET..." ?


            TOXCCT >>> GEII power

            [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

            E Offline
            E Offline
            ebruinsma
            wrote on last edited by
            #5

            Sorry, I don't know what the diference is between those languages:confused:, I thought that when I use MicroSoft's visual C++ that I was using c++, with their compiler. How can I see what I'm using. What I did to create the project, was: Choose new project from the file menu, and choose: visual c++ project/.net/ ASP.NET web service. So, my question still is what do I need to do, to get a webservice that allows me to call runscrip in InDesign. TIA Erik.

            T 1 Reply Last reply
            0
            • E ebruinsma

              Sorry, I don't know what the diference is between those languages:confused:, I thought that when I use MicroSoft's visual C++ that I was using c++, with their compiler. How can I see what I'm using. What I did to create the project, was: Choose new project from the file menu, and choose: visual c++ project/.net/ ASP.NET web service. So, my question still is what do I need to do, to get a webservice that allows me to call runscrip in InDesign. TIA Erik.

              T Offline
              T Offline
              toxcct
              wrote on last edited by
              #6

              ebruinsma wrote:

              I thought that when I use MicroSoft's visual C++ that I was using c++, with their compiler.

              yes, that is an obvious thought. unfortunately, MS Visual C++ .NET 2003 (and later) compiler understands 2 different kind of C++ : Native (pure console, Win32, MFC/ATL/WTL projects) Managed (the one compiled for .net framework). it seems that you created a managed C++ project, so you code in Managed C++ (also called C++/CLI in newer version of the language). unfortunately, this is not the right forum to ask such a question (most people here don't know MC++), so, i suggest you to ask it here[^] to get better answers ;)


              TOXCCT >>> GEII power

              [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

              E 1 Reply Last reply
              0
              • T toxcct

                ebruinsma wrote:

                I thought that when I use MicroSoft's visual C++ that I was using c++, with their compiler.

                yes, that is an obvious thought. unfortunately, MS Visual C++ .NET 2003 (and later) compiler understands 2 different kind of C++ : Native (pure console, Win32, MFC/ATL/WTL projects) Managed (the one compiled for .net framework). it seems that you created a managed C++ project, so you code in Managed C++ (also called C++/CLI in newer version of the language). unfortunately, this is not the right forum to ask such a question (most people here don't know MC++), so, i suggest you to ask it here[^] to get better answers ;)


                TOXCCT >>> GEII power

                [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                E Offline
                E Offline
                ebruinsma
                wrote on last edited by
                #7

                Ok, I'll try it there. Thanx

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups