(Excel and Vensim)link

Use this forum to post Vensim related questions.
Administrator
Super Administrator
Posts: 4842
Joined: Wed Mar 05, 2003 3:10 am

Re: (Excel and Vensim)link

Post by Administrator »

Install the Vensim Model Reader (not PLE).
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Re: (Excel and Vensim)link

Post by ahmadi2010 »

You are right. I selected the wrong option.

I try to install it but:
Attachments
pic.jpg
pic.jpg (27.99 KiB) Viewed 23145 times
Administrator
Super Administrator
Posts: 4842
Joined: Wed Mar 05, 2003 3:10 am

Re: (Excel and Vensim)link

Post by Administrator »

Can you try downloading again? It may be that the download was corrupted.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Re: (Excel and Vensim)link

Post by ahmadi2010 »

I could try to downloading it again. I could install it.
But :
Attachments
Pic2.jpg
Pic2.jpg (95.69 KiB) Viewed 23143 times
Administrator
Super Administrator
Posts: 4842
Joined: Wed Mar 05, 2003 3:10 am

Re: (Excel and Vensim)link

Post by Administrator »

Open Excel, you do not need the model reader or Vensim DSS open.

Now run the "RunModelMultipleTimes" macro.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Re: (Excel and Vensim)link

Post by ahmadi2010 »

Thank you Tony .

I'm Sorry to bother you.

I do as you said. It gives the same error. always, I have to open the Vensim program at first. if I don't open it ,I can't run any macro.

I'm not hoping that my DLL works. I think I have to find a way to change the model that Tom edited for me. I can work with DDE problem easily. :(
Administrator
Super Administrator
Posts: 4842
Joined: Wed Mar 05, 2003 3:10 am

Re: (Excel and Vensim)link

Post by Administrator »

You do not need the model open in Vensim for it to work.

What happens when you run the macro?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Re: (Excel and Vensim)link

Post by ahmadi2010 »

In my models (not Book2), I have to run these macros and Vensim should be open:

Code: Select all

Sub StartupDDE()

DDE_channel = Application.DDEInitiate("VENSIM", "System")

End Sub
Sub LoadVensimModel()

varstr$ = "[SPECIAL>LOADMODEL|" + Cells(2, 7).Value + "]"

Application.DDEExecute DDE_channel, varstr$

End Sub
And then I can run other macros.

In Book2(the model that you edited for me) ,with or without opening vensim the error is:
Attachments
pic.jpg
pic.jpg (19.58 KiB) Viewed 23135 times
Administrator
Super Administrator
Posts: 4842
Joined: Wed Mar 05, 2003 3:10 am

Re: (Excel and Vensim)link

Post by Administrator »

ok. Try publishing the model again, select package type "Other (using Vensim DLL)" and selecting the "caller" as Excel. You will need to look into the help system to do this properly.

If you can reinstall Vensim DSS ensuring that vendll32.dll is installed, it will all work ok for you. You mentioned in a previous post that you installed lots of times, but then said someone installed Vensim for you. If someone installed it for you, get them to install again and make sure the DLL is installed correctly.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Re: (Excel and Vensim)link

Post by ahmadi2010 »

Thank you Tony for your help. :)

Yes, someone installed it for me for 5 times at a day, But vendll32.dll automatically saved at "C:\Windows\System32". They selected the DLL option at each time. and don't give me this software. :wink:
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Re: (Excel and Vensim)link

Post by ahmadi2010 »

Your forum is the best forum that I've ever seen. I'm really grateful to you .
You help me so much, but finally because of software problem I can't get result.
Administrator
Super Administrator
Posts: 4842
Joined: Wed Mar 05, 2003 3:10 am

Re: (Excel and Vensim)link

Post by Administrator »

In the last example I sent, I modified the code to load vendll32.dll from c:\windows\system32.

In the VBA file, at the top it should look like this (I changed "vendll32.dll" to "C:\Windows\System32\vendll32.dll", so it should work on your computer).

Code: Select all

Private Declare Function vensim_be_quiet Lib "C:\Windows\System32\vendll32.dll" (ByVal quietflag As Long) As Long
Private Declare Function vensim_check_status Lib "C:\Windows\System32\vendll32.dll" () As Long
Private Declare Function vensim_command Lib "C:\Windows\System32\vendll32.dll" (ByVal Vcommand$) As Long
Private Declare Function vensim_continue_simulation Lib "C:\Windows\System32\vendll32.dll" (ByVal number_time_step As Long) As Long
Private Declare Function vensim_finish_simulation Lib "C:\Windows\System32\vendll32.dll" () As Long
Private Declare Function vensim_get_data Lib "C:\Windows\System32\vendll32.dll" (ByVal filename$, ByVal varname$, ByVal timename$, varvals As Single, timevals As Single, ByVal maxpoints As Integer) As Long
Private Declare Function vensim_get_dpval Lib "C:\Windows\System32\vendll32.dll" (ByVal varname$, varval As Double) As Long
Private Declare Function vensim_get_dpvecvals Lib "C:\Windows\System32\vendll32.dll" (vecoff As Long, varvals As Double, ByVal veclen As Long) As Long
Private Declare Function vensim_get_info Lib "C:\Windows\System32\vendll32.dll" (ByVal infowanted As Long, ByVal buf$, ByVal maxbuflen As Long) As Long
Private Declare Function vensim_get_sens_at_time Lib "C:\Windows\System32\vendll32.dll" (ByVal filename$, ByVal varname$, ByVal timename$, attime As Single, vals As Single, ByVal maxpoint As Long) As Long
Private Declare Function vensim_get_substring Lib "C:\Windows\System32\vendll32.dll" (ByVal fullstring$, ByVal frompos As Long, ByVal buf$, ByVal maxbuflen As Long) As Long
Private Declare Function vensim_get_val Lib "C:\Windows\System32\vendll32.dll" (ByVal varname$, varval As Single) As Integer
Private Declare Function vensim_get_varattrib Lib "C:\Windows\System32\vendll32.dll" (ByVal varname$, ByVal attrib As Long, ByVal buf$, ByVal maxbuflen As Long) As Long
Private Declare Function vensim_get_varnames Lib "C:\Windows\System32\vendll32.dll" (ByVal filter$, ByVal vartype As Long, ByVal buf$, ByVal maxbuflen As Long) As Long
Private Declare Function vensim_get_varoff Lib "C:\Windows\System32\vendll32.dll" (ByVal varname$) As Long
Private Declare Function vensim_get_vecvals Lib "C:\Windows\System32\vendll32.dll" (vecoff As Long, varvals As Single, ByVal nelm As Long) As Long
Private Declare Function vensim_set_parent_window Lib "C:\Windows\System32\vendll32.dll" (ByVal vwidnow As Long, ByVal r1 As Long, ByVal r2 As Long) As Long
Private Declare Function vensim_show_sketch Lib "C:\Windows\System32\vendll32.dll" (ByVal viewnum As Long, ByVal wantscroll As Long, ByVal zoompercent As Long, ByVal Vwindow As Long) As Long
Private Declare Function vensim_start_simulation Lib "C:\Windows\System32\vendll32.dll" (ByVal loadfirst As Integer, ByVal game As Long, ByVal overwrite As Long) As Long
Private Declare Function vensim_tool_command Lib "C:\Windows\System32\vendll32.dll" (ByVal Vcommand$, ByVal Vwindow As Long, ByVal iswip As Long) As Long
Is this the code you are using?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Re: (Excel and Vensim)link

Post by ahmadi2010 »

Yes, I'm using this code. and for first time , after I run the macro Vensim first page appears and then gives the same error.
Administrator
Super Administrator
Posts: 4842
Joined: Wed Mar 05, 2003 3:10 am

Re: (Excel and Vensim)link

Post by Administrator »

"Vensim first page appears", do you mean the startup screen? If it does, then it should be working.

What error appears after the Vensim first page?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Re: (Excel and Vensim)link

Post by ahmadi2010 »

Yes, I mean startup screen.
this error:
Attachments
pic.jpg
pic.jpg (19.58 KiB) Viewed 23129 times
Administrator
Super Administrator
Posts: 4842
Joined: Wed Mar 05, 2003 3:10 am

Re: (Excel and Vensim)link

Post by Administrator »

Can you send me an email (vensim@vensim.com) with your Vensim serial number (click Help->About Vensim) and I'll try and get the correct DLL for you.

If you have the unlock code that would be better.

Tony.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
ahmadi2010
Senior Member
Posts: 77
Joined: Thu Aug 19, 2010 3:34 pm

Re: (Excel and Vensim)link

Post by ahmadi2010 »

Tony:

I've just sent an email for you.
khairahnazurahkarim
Newbie
Posts: 1
Joined: Thu Aug 21, 2014 6:21 am
Vensim version: DSS

Re: (Excel and Vensim)link

Post by khairahnazurahkarim »

Tony,

i would like to access the following files uploaded but are unable to do so, im having the same issues with linking vensim and vba
would you mind uploading another copy of the following files:

Book2.xslm
2010-12-10 model.zip
model.rar

thank you
Administrator
Super Administrator
Posts: 4842
Joined: Wed Mar 05, 2003 3:10 am

Re: (Excel and Vensim)link

Post by Administrator »

The files download fine for me. Try a different browser.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Post Reply