PRB: Unable to Access Script in ALX from Script in HTML

ID: Q163397


The information in this article applies to:


SYMPTOMS

When attempting to invoke a script embedded in an .alx file from a script in an HTML page, which references that ALX via an HTML Layout control, the following error occurs:

VBScript runtime error. Line <n>: Type Mismatch


RESOLUTION

The following two steps are required to work around this problem:

  1. Upgrade to Microsoft Visual Basic, Scripting Edition, version 2.0 or later.


  2. Place the common code that needs to be executed by both the HTML and the ALX in the HTML file. While scripts in an HTML file cannot invoke scripts in an ALX file, scripts embedded in an ALX file can invoke scripts embedded in the containing HTML file.


In VBSCRIPT 1.0, scripts could not be invoked in either direction and instead yielded the following error:
VBScript runtime error. Line <n>: Type Mismatch


STATUS

This behavior is by design.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Launch Notepad, and copy and paste the following code into the file:
    
    <HTML>
    <HEAD>
    <TITLE>New Page</TITLE>
    
    <SCRIPT LANGUAGE=VBSCRIPT>
    Sub cmdHtm_Click
       ' Demonstrates the inability of the container to call
       ' contained code
       ' Clicking on cmdHTM will generate a scripting error
       ALXFunc
    End Sub
    
    Sub HTMFunc()
       ' Demonstrates the ability to call code from the container
       MsgBox "Code in the HTML file was invoked!"
    End Sub
    
    Sub cmdChangeALXButtonProps_Click()
       ' Demonstrates the it's possible for code in an HTML file to
       ' modify the properties of object contained in an embedded ALX.
       layout1_alx.cmdAlx.caption = "Click me!"
       layout1_alx.cmdAlx.backColor = &h80000010
    End Sub
    </SCRIPT>
    </HEAD>
    <BODY>
    
    <OBJECT ID="cmdHtm" WIDTH=99 HEIGHT=88
              CLASSID="CLSID:D7053240-CE69-11CD-A777-00DD01143C57">
        <PARAM NAME="Caption" VALUE="Button in HTML">
        <PARAM NAME="Size" VALUE="2611;2328">
        <PARAM NAME="ParagraphAlign" VALUE="3">
    </OBJECT>
    <P>
    <OBJECT ID="cmdChangeALXButtonProps"
             CLASSID="CLSID:D7053240-CE69-11CD-A777-00DD01143C57"
             STYLE=
            "TOP:150pt;LEFT:100pt;WIDTH:74pt;HEIGHT:66pt;TABINDEX:0;ZINDEX:0;">
       <PARAM NAME="Caption" VALUE="Change Caption">
       <PARAM NAME="Size" VALUE="2611;2338">
       <PARAM NAME="ParagraphAlign" VALUE="3">
    </OBJECT>
    <P>
    <OBJECT ID="layout1_alx"
      CLASSID="CLSID:812AE312-8B8E-11CF-93C8-00AA00C08FDF"
       STYLE="LEFT:0;TOP:0">
       <PARAM NAME="ALXPATH" REF VALUE="oneway.alx"
    </OBJECT>
    </BODY>
    </HTML> 


  2. Save the file as Oneway.htm.


  3. Create a new file, copy and paste the following code into the new file:
    
    <SCRIPT LANGUAGE="VBS">
    Sub cmdAlx_Click
       ' Demonstrates invoking code located in containing HTML
       HTMFunc
    End Sub
    
    Sub ALXFunc()
       ' Demonstrates the inability of the container to call
       ' contained code
       MsgBox "Code in ALX was invoked!"
    End Sub
    </SCRIPT>
    
    <DIV ID="layout1" STYLE="LAYOUT:FIXED;WIDTH:78pt;HEIGHT:69pt;">
    <OBJECT ID="cmdAlx"
             CLASSID="CLSID:D7053240-CE69-11CD-A777-00DD01143C57"
             STYLE=
                "TOP:0pt;LEFT:0pt;WIDTH:74pt;HEIGHT:66pt;TABINDEX:0;ZINDEX:0;">
       <PARAM NAME="Caption" VALUE="ALX Button">
       <PARAM NAME="Size" VALUE="2611;2328">
       <PARAM NAME="ParagraphAlign" VALUE="3">
    </OBJECT>
    </DIV> 


  4. Save the file as Oneway.alx in the same directory as Oneway.htm.


  5. Launch Internet Explorer 3.x or greater, and load Oneway.htm.


  6. Click on the button labeled "ALX Button," and observe the message box indicating that code in the HTML file has been executed. This demonstrates that it's possible from code in an ALX file to call script code located in the containing HTML file.


  7. Click on the button labeled "Button in HTML," and observe the VBSCRIPT error indicating that it isn't possible from an HTML file to execute \ code embedded in an ALX file.


  8. Click on the button labeled "Change Caption," and observe that it is possible from a containing HTML file to change the properties of objects contained in a referenced ALX file.


Additional query words:


Keywords          : kbIE500 AXSDKScripting 
Version           : 2.00
Platform          : WINDOWS 
Issue type        : 

Last Reviewed: July 2, 1999