Microsoft KB Archive/163397

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

Article ID: 163397

Article Last Modified on 6/12/2001

-

APPLIES TO


 * Microsoft Visual Basic, Scripting Edition 2.0

-



This article was previously published under Q163397



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 : 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 : Type Mismatch



STATUS
This behavior is by design.



Steps to Reproduce Behavior
  Launch Notepad, and copy and paste the following code into the file:   New Page

 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   <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> </li> <li>Save the file as Oneway.htm.</li> <li> 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> </li> <li>Save the file as Oneway.alx in the same directory as Oneway.htm.</li> <li>Launch Internet Explorer 3.x or greater, and load Oneway.htm.</li> <li>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.</li> <li>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.</li> <li>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.</li></ol>

Keywords: KB163397

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.