M
Martin Waller
Hello,
The problem I am having is I don't know for sure what version of the OWC the
client has installed when the ASP page is run. To get round this problem I'm
depositing a <DIV> tag in the HTML sent to the client and running client
side Javascript to detect the OWC version and hence the class id by reading
the registry and then replacing the innerHTML associated with the <DIV> with
an <OBJECT> tag for the OWC component. The code to return the class id given
below and the code to do the replacement looks like:
SS = SpreadSheetClassID(); // Get the OWC SpreadSheet Class ID
if (SS.length != 0) // If we have one installed
{
//
// At this point the HTML for the page does not have the
<OBJECT> tag
// referencing the SpreadSheet in it. It simply has a <DIV> tag
that is
// being used as a place holder. Here we need to replace the
HTML for
// the <DIV> with the <OBJECT> tag that references the correct
OWC
// Spreadsheet component.
//
OWCDIV.innerHTML = "<object classid='clsid:" + SS + "'
id='Spreadsheet' width='100%' height='100%'></object>";
}
function SpreadSheetClassID()
/*
* FUNCTION: SpreadSheetClassID() -> String
*
* This function is called to determine the class id string
* for the OWC Spreadsheet if it is installed. If it is not
* installed then it will return a zero length string.
*/
{
var oshell; // WScript shell object
var s; // Simple string
oshell = new ActiveXObject("WSCript.shell"); // Create a script engine
object
//
// Start by looking for OWC11.Spreadsheet
//
try
{
s = oshell.RegRead("HKCR\\OWC11.Spreadsheet\\CLSID\\");
return s.substring(1,s.length - 1); // Return the class id
}
catch (e) // Catch any error
{ }
//
// Next we can try OWC10.Spreadsheet
//
try
{
s = oshell.RegRead("HKCR\\OWC10.Spreadsheet\\CLSID\\");
// Read the key value
return s.substring(1,s.length - 1); // Return the class id
}
catch (e) // Catch any error
{ }
//
// Finally we can try OWC.Spreadsheet
//
try
{
s = oshell.RegRead("HKCR\\OWC.Spreadsheet\\CLSID\\");
// Read the key value
return s.substring(1,s.length - 1); // Return the class id
}
catch (e) // Catch any error
{
return ""; // Return an empty string
}
}
Comments ?
Martin
The problem I am having is I don't know for sure what version of the OWC the
client has installed when the ASP page is run. To get round this problem I'm
depositing a <DIV> tag in the HTML sent to the client and running client
side Javascript to detect the OWC version and hence the class id by reading
the registry and then replacing the innerHTML associated with the <DIV> with
an <OBJECT> tag for the OWC component. The code to return the class id given
below and the code to do the replacement looks like:
SS = SpreadSheetClassID(); // Get the OWC SpreadSheet Class ID
if (SS.length != 0) // If we have one installed
{
//
// At this point the HTML for the page does not have the
<OBJECT> tag
// referencing the SpreadSheet in it. It simply has a <DIV> tag
that is
// being used as a place holder. Here we need to replace the
HTML for
// the <DIV> with the <OBJECT> tag that references the correct
OWC
// Spreadsheet component.
//
OWCDIV.innerHTML = "<object classid='clsid:" + SS + "'
id='Spreadsheet' width='100%' height='100%'></object>";
}
function SpreadSheetClassID()
/*
* FUNCTION: SpreadSheetClassID() -> String
*
* This function is called to determine the class id string
* for the OWC Spreadsheet if it is installed. If it is not
* installed then it will return a zero length string.
*/
{
var oshell; // WScript shell object
var s; // Simple string
oshell = new ActiveXObject("WSCript.shell"); // Create a script engine
object
//
// Start by looking for OWC11.Spreadsheet
//
try
{
s = oshell.RegRead("HKCR\\OWC11.Spreadsheet\\CLSID\\");
return s.substring(1,s.length - 1); // Return the class id
}
catch (e) // Catch any error
{ }
//
// Next we can try OWC10.Spreadsheet
//
try
{
s = oshell.RegRead("HKCR\\OWC10.Spreadsheet\\CLSID\\");
// Read the key value
return s.substring(1,s.length - 1); // Return the class id
}
catch (e) // Catch any error
{ }
//
// Finally we can try OWC.Spreadsheet
//
try
{
s = oshell.RegRead("HKCR\\OWC.Spreadsheet\\CLSID\\");
// Read the key value
return s.substring(1,s.length - 1); // Return the class id
}
catch (e) // Catch any error
{
return ""; // Return an empty string
}
}
Comments ?
Martin