Page 1 of 1

LOADMODEL does not work from Excel

Posted: Tue Sep 16, 2014 2:40 pm
by linear feedback
Hello, I am trying to run a Vensim model from Excel through the DLL-interface.

To test things I have changed the example code in vendll.xls so that Excel and Vensim work in the directory in which both Excel and Vensim are located.

Sub Get_Vensim_Info()
Dim buf As String * 512

Dim MyPath As String
MyPath = ActiveWorkbook.Path
ChDir MyPath
result = vensim_check_status()
result = vensim_command("SPECIAL>LOADMODEL|worldapp.vpm")

Problem is that the model is not loaded. Result equals '6' after vensim_check_status() - which is confusing as I run this on a freshly booted machine without starting Vensim before testing this - and '0' after loadmodel.

Any ideas?
Win 7 64bit & 6.0b

Re: LOADMODEL does not work from Excel

Posted: Tue Sep 16, 2014 2:56 pm
by tomfid
What makes you think it's not loaded? Getting a 0 from check_status after a LOADMODEL could be normal.

What if you call vensim_get_info with 5 for the current model name? Or issue a MENU>RUN|o command?

Re: LOADMODEL does not work from Excel

Posted: Tue Sep 16, 2014 3:41 pm
by linear feedback
Thank you for the swift reply. Apologies for being to brief in my descropition: If I let the vba-code of the demo continue to run all vensim_get_info is empty which makes me suspect the loadmodel does not work. I have a similar issue with a model I have developed where the Run has no effect. I hope this clarifes my problem.

Re: LOADMODEL does not work from Excel

Posted: Tue Sep 16, 2014 4:48 pm
by Administrator
What happens if you put the full path into loadmodel?

Re: LOADMODEL does not work from Excel

Posted: Tue Sep 16, 2014 5:16 pm
by linear feedback
Putting the full path in the LOADMODEL has the same outcome

Re: LOADMODEL does not work from Excel

Posted: Tue Sep 16, 2014 5:55 pm
by tomfid
Is the result from vensim_command("SPECIAL>LOADMODEL|worldapp.vpm") a 0 or 1?

Re: LOADMODEL does not work from Excel

Posted: Tue Sep 16, 2014 8:03 pm
by linear feedback
0 (in all tests)

Re: LOADMODEL does not work from Excel

Posted: Wed Sep 17, 2014 7:15 am
by Administrator
Can you upload your code so we can take a look? Zip the directory you are testing with and then we can try running it on our machines.

Tony.

Re: LOADMODEL does not work from Excel

Posted: Wed Sep 17, 2014 7:39 am
by linear feedback
See the attached. I took the vendll.xls and included the directory change as indicated in my first post.

Re: LOADMODEL does not work from Excel

Posted: Wed Sep 17, 2014 8:55 am
by Administrator
It works fine for me.

Do you have the Vensim model reader installed as well?

Re: LOADMODEL does not work from Excel

Posted: Wed Sep 17, 2014 9:53 am
by linear feedback
No - I don't think so. In the Start menu / Vensim there is only a reference to Vensim DSS.

Re: LOADMODEL does not work from Excel

Posted: Thu Sep 18, 2014 7:35 am
by Administrator
What happens if you run Get_Vensim_Info() in the attached? It should fill in the cells F21-Z21 in the spreadsheet.

Re: LOADMODEL does not work from Excel

Posted: Thu Sep 18, 2014 7:58 am
by linear feedback
All cells are empty. I single-stepped through the macro and length = '-1' and buf = ''

Re: LOADMODEL does not work from Excel

Posted: Thu Sep 18, 2014 8:19 am
by Administrator
Can you try putting it in a different path (eg, c:\test)?

Re: LOADMODEL does not work from Excel

Posted: Thu Sep 18, 2014 9:11 am
by linear feedback
Tried again and no difference. (To mitigate that possible factor I incuded the forced path change in the macros)

Re: LOADMODEL does not work from Excel

Posted: Thu Sep 18, 2014 11:46 am
by Administrator
Do you have a vendll32.dll file in c:\users\public\vensim? Or in c:\users\public\vensim\dll?

If so, delete it and then what happens?

Re: LOADMODEL does not work from Excel

Posted: Fri Sep 19, 2014 12:04 am
by linear feedback
No, I do not have a vendll32.dll in any of those directories. I did a search on C: and I have the dll in
C:\Users\'Username'\Vensim\dll
C:\Users\'Username'\Appdata\local\Vensim
C:\Windows\SysWOW64
and in the directory the Excel file and the model are located.

All dlls have the same length and save date.

Re: LOADMODEL does not work from Excel

Posted: Fri Sep 19, 2014 6:33 am
by Administrator
I think you will need to reinstall Vensim.

Then make sure you have deleted the DLLs from C:\Users\'Username'\Vensim\dll and C:\Users\'Username'\Appdata\local\Vensim

Do not copy anything into C:\Windows\SysWOW64.