View Single Post
  #1 (permalink)  
Old April 20th, 2004, 03:41 PM
cdukes77@bellsouth.net cdukes77@bellsouth.net is offline
Registered User
 
Join Date: Apr 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cannot create ActiveX component problem

First, I'm a newbie to .Net ... Any help is appreciated.

So I see that one of the applications I frequently use (Adobe InDesign) can be driven using VB ... I decide to try it out ... if this works, there are many day-to-day work flow problems that I can address. First I try creating a VB executable (using Visual Studio .NET 2003) with a simple button ... the code behind the button is:


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        REM Hello World
        REM Declare variable types (optional if Option Explicit is off).
        Dim myInDesign As InDesign.Application
        Dim myDocument As InDesign.Document
        Dim myPage As InDesign.Page
        Dim myTextFrame As InDesign.TextFrame
        REM End of variable type declarations
        myInDesign = CreateObject("InDesign.Application.CS")
        REM Create a new document
        myDocument = myInDesign.Documents.Add
        REM Get a reference to the first page
        myPage = myDocument.Pages.Item(1)
        REM Create a text frame
        myTextFrame = myDocument.TextFrames.Add
        REM Specify the size and shape of the text frame
        Dim AryStringArray() As String = {"0p0", "0p0", "18p0", "18p0"}
        myTextFrame.GeometricBounds = AryStringArray
        REM Enter text in the text frame
        myTextFrame.Contents = "Hello World!"
    End Sub
End Class

(I added the Interop.InDesign reference to my project)

I compile and run it ... no problem, everything works ... cool ... then I decide to try the same thing from an aspx page ...

First I tried something simple and just copied and pasted the code into a button placed on an aspx page ... result when I tried the page in my browser ... "Cannot create ActiveX component "

I continued reading, and though nothing specifically said what the problem was I got the feeling there was a permission problem, someplace.

So ... tried creating a VB class (see code below):

Imports System
Imports InDesign

Namespace WroxUnited
    Public Class Class1
        Public Sub New()
        End Sub
        Public Function runInDesign()
            REM Hello World
            REM Declare variable types (optional if Option Explicit is off).
            Dim myInDesign As InDesign.Application
            Dim myDocument As InDesign.Document
            Dim myPage As InDesign.Page
            Dim myTextFrame As InDesign.TextFrame
            REM End of variable type declarations
            myInDesign = CreateObject("InDesign.Application.CS")
            REM Create a new document
            myDocument = myInDesign.Documents.Add
            REM Get a reference to the first page
            myPage = myDocument.Pages.Item(1)
            REM Create a text frame
            myTextFrame = myDocument.TextFrames.Add
            REM Specify the size and shape of the text frame
            Dim AryStringArray() As String = {"0p0", "0p0", "18p0", "18p0"}
            myTextFrame.GeometricBounds = AryStringArray
            REM Enter text in the text frame
            myTextFrame.Contents = "Hello World!"
            Return "Done"
        End Function
    End Class
End Namespace


... then calling the VB class from the button (see code below):

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ClassTest As New WroxUnited.Class1
        Dim lblMessage
        lblMessage = ClassTest.runInDesign
    End Sub


Result when I tried to test ... ... "Cannot create ActiveX component " ...

Kept reading ... found a reference that indicated that the ASPNET user account might need to be given Administrator rights ...
tried that ... same result ...

I'm obviously missing something here, but I seem to see variants of the question from several other people. Any ideas?

I have gotten a hint that I may need to register an ActiveX object using the regsvr32.exe utility ... but the question is (if this is the answer) what ActiveX object.


Reply With Quote