I’m in need of running a vbscript with an argument from a webpage. More specifically from a Sharepoint 2010 page. What I’m trying to do is to open SuperOffice and a specific document template. And in doing so, I’ve got this code to do just that.
startSOTemplate("Anbudsbrev")
Public Sub startSOTemplate(parameter)
Dim objSO
Set objSO = CreateObject("SuperOffice.Application")
If not (ObjSO is nothing) then
objSO.CurrentDocument.ChangeIdentity 0
objSO.CurrentDocument.SetDefaults
objSO.Context.Set "superoffice: document"
objSO.CurrentDocument.Template = objSO.Database.GetListItemByName(130, parameter)
End if
End Sub
Now, I’ve tried to add this script to a webpage using this code (The link will be replaced by a button later on)
<HTML>
<HEAD><TITLE>A Simple First Page</TITLE>
<SCRIPT LANGUAGE="VBScript">
<!--
Public Sub myVBFunction(parameter)
Dim objSO
Set objSO = CreateObject("SuperOffice.Application")
If not (objSO is nothing) Then
objSO.CurrentDocument.ChangeIdentity 0
objSO.CurrentDocument.SetDefaults
objSO.Context.Set "superoffice: document"
objSO.CurrentDocument.Template = objSO.Database.GetListItemByName(130, parameter)
end if
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<H3>A Simple First Page</H3><HR>
<a href="#" onclick="VBscript:myVBFunction('Anbudsbrev')">link</a>
</BODY>
</HTML>
And what happens is that I get an error on the webpage saying ActiveX component can't create object: 'SuperOffice.Application'. I know the dll is registered correctly, because it does work using a vbs-script alone.
So, my real question is this: Is a better way of achieving the same thing? Perhaps run the vbscript from a file instead? And just use the link on each button?
A couple of potential gotchas:
Is your operating system 64 bit? If so, you must ensure that you run the correct browser (Internet Explorer comes with both 32 bit and 64 bit). Not all COM objects are available / visible in both.
Does your
SuperOffice.Applicationaccess your local registry or file system? If so, then your COM object is sandboxed. One way around this is to host your HTML page inside an HTML Application by using the.htafile extension instead of.htmlwhich will allow your HTML page to execute as a “fully trusted” application. See Wikipedia’s definition of HTML Application.