Subject: Componente Activex não pode criar Objeto Posted: 9/8/2023 Viewed: 650 times
I am trying to run the sample script to access Weap but the error message "ActiveX Component cannot create Object" appears. I tested in Windows 10 and got no problems, but when exceeded in Windows 11 appears an error.
There is some incompatibility of Windows versions with the script.
Mr. Jack Sieber
Subject: Re: Componente Activex não pode criar Objeto Posted: 9/8/2023 Viewed: 619 times
What language is the script written in? Visual Basic? Python? If it is Python, can you please tell me what version of Python it is? What is the text of the script you are trying?
Eng. Fabiano da Silva de Oliveira
Subject: Re: Componente Activex não pode criar Objeto Posted: 9/11/2023 Viewed: 531 times
Here is the code snippet that works on Windows 10, but not on Windows 11. It is running on Visual Studio 2022 on both operating systems:
public static void Calcular()
dynamic WEAP = Activator.CreateInstance(Type.GetTypeFromProgID("WEAP.WEAPApplication"));
for (int GrowthRate = 0; GrowthRate <= 5; GrowthRate++)
//corrigir pois os valores aparecem os mesmo na planilha de excel.
WEAP.Branch("\\Demand Sites\\South City").Variables["Annual Activity Level"].Expression = "Growth(" + GrowthRate.ToString("N0") + "%)";
// WEAP.Calculate(0, 0, false); // Only calculate scenarios that need calculation (for all years and timesteps)
// Atualize o TextBox no Form1 do namespace Acesso_Weap
// WEAP will close automatically when the script is done, and the changes will NOT be saved to the area
Mr. Jack Sieber
Subject: Re: Componente Activex não pode criar Objeto Posted: 9/13/2023 Viewed: 516 times
I do not have Visual Studio, so I could not test your Visual Basic code, but I did test a simple Visual Basic Script (below) in Windows 11 and it worked fine.
Perhaps WEAP is not registered correctly in your Windows 11 system? To check this, open WEAP, then go to Help, About. Near the bottom of the first section ("WEAP"), it will tell you if it is registered correctly in the Windows Registry. It should say "WEAP is registered correctly in the Windows Registry"
If WEAP is NOT registered correctly, try running the batch file RegisterWEAP.bat, which is located in the WEAP program folder, e.g., c:\Program Files (x86)\WEAP. You will need to run the batch file As Administrator.
Here is the simple script I tested:
' Run WEAP as a COM Automation Server
Set WEAP = CreateObject("WEAP.WEAPApplication")
' Make sure WEAP is fully started
While Not WEAP.ProgramStarted
WEAP.Verbose = 1 ' 0 = no dialogs, 1 = errors only, 2 = questions & errors, 3 = warnings, questions & errors, 4 = all dialogs
WEAP.Logfile = WEAP.Directory + "WeapErrors.txt" ' log all errors and warnings to this text file
WEAP.ActiveArea = "Weaping River Basin"
WEAP.ActiveScenario = "Supply Measures"
Sleep (5) ' Make sure WEAP has started
FOR GrowthRate = 0 to 5 ' try various growth rates