CreateObject not working?

Add-in Express™ Support Service
That's what is more important than anything else

CreateObject not working?
 
Subscribe
Norman Neubert




Posts: 13
Joined: 2022-06-09
Hi, I use the following code so I can use VB-Script within my addin.

It works fine in normal windows forms application.

For my Plugin in I use AnyCPU. The currently installed Excel is 32 Bit.

Creation of G_ScriptEngine works fine. But assigning the language "VBScript" fails with this error:

"A script engine for the specified language can not be created."

Tested it with x86 instead of any cpu. Fails, too.

Any idea why this doesnt work? Thanks in advance!

Kind regards
Norman



                Try
                    G_ScriptEngine = CreateObject("MSScriptControl.ScriptControl")
                Catch
                End Try

                If Not (G_ScriptEngine Is Nothing) Then
                    G_ScriptEngine.Language = "VBScript"
                End If

Posted 01 Apr, 2024 17:07:23 Top
Andrei Smolin


Add-in Express team


Posts: 18833
Joined: 2006-05-11
Hello Norman,

Consider this VBA macro:

Sub dsgsdfsfdh()
Dim G_ScriptEngine As Object
    Set G_ScriptEngine = CreateObject("MSScriptControl.ScriptControl")
 
If Not (G_ScriptEngine Is Nothing) Then
    Stop
    G_ScriptEngine.Language = "VBScript"
End If

Stop
End Sub


When run in Excel, it fires an error on the G_ScriptEngine.Language = "VBScript" line; the error message is "Invalid property value". In Outlook, the macro works as expected.

You wrote:
It works fine in normal windows forms application.


I confirm, it doesn't fail in a Windows Forms application. But does it work after that?

Regards from Poland (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 03 Apr, 2024 15:02:04 Top
Norman Neubert




Posts: 13
Joined: 2022-06-09
Hi Andrei,

thank you for your reply. I tried with STOP. The error stays the same: "A script engine for the specified language can not be created."

Kind regards
Norman
Posted 03 Apr, 2024 19:10:23 Top
Andrei Smolin


Add-in Express team


Posts: 18833
Joined: 2006-05-11
Hello Norman,

Sorry, I don't have any idea where to move next.

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 08 Apr, 2024 08:56:35 Top
Norman Neubert




Posts: 13
Joined: 2022-06-09
Thank you Andrei, anyone else an idea why this doesn't work?
Posted 09 Apr, 2024 07:15:22 Top
Andrei Smolin


Add-in Express team


Posts: 18833
Joined: 2006-05-11
Hello Norman,

I suggest that you ask this question on StackOverflow.com.

Regards from Poland (GMT+1),

Andrei Smolin
Add-in Express Team Leader
Posted 10 Apr, 2024 11:15:50 Top