0

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?

1 Answer 1

1

A couple of potential gotchas:

  1. 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.

  2. Does your SuperOffice.Application access 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 .hta file extension instead of .html which will allow your HTML page to execute as a "fully trusted" application. See Wikipedia's definition of HTML Application.

Sign up to request clarification or add additional context in comments.

5 Comments

That last bit worked! Ok, so I have not pinpointed the exact reason this doesn't work. It's a DCOM security issue then? I tried opening dcomcnfg.exe, but I might have to fiddle around a bit in there to make it work. I can't exactly use a .hta file extension in Sharepoint 2010 can I?
Okay, it does seems like a browser security issue. Assuming that is the case, you need to review your means of deploying your webpage. A simple solution is to provide the .hta as a shared document in SharePoint.
Just though of something. How about I register the script as a protocol? Or perhaps I'll have to convert the vbscript to an exe and then register that as a protocol? That way I can probably do something like openSOTemplate://myargument ?
Seems like a lot of work, but if you think that achieves what you want, why not. Personally, I think moving your webpage inside a .hta file and sharing that .hta file in SharePoint does the job.
I just made that protocol and it works just as I planned :) I can't just wrap a Sharepoint 2010 site inside a .hta file either. Because it's based on SharePoint lists anyway. So that would be a bigger job alltogether

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.