cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

The PTC Community email address has changed to community-mailer@ptc.com. Learn more.

VB API with MS Excel

JoeVarghese
1-Newbie

VB API with MS Excel

Hi, I am using WF4 and VB API. I could link link proe to MS Excel using VBA commands. I could retrieve the active model from session. But I have a problem in accessing parameters as suggested by PTC. In one of the examples that PTC provided, it acceesses the parameters the following way.

anonymous wrote:

Dim params As CpfcParameters Dim model As IpfcModel . . model = session.CurrentModel params = model.ListParams()


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
10 REPLIES 10

Hi, you managed it to run VP API via MS Excel 2003. When I tried to run it with the example, it fails although I have followed the instructions. I know this question has nothing to do with your problem, but can you tell me how you did it? Maybe I can figure out your problem when I can make it run on my system.

Yes I could do that thanks to Marc.. see his blog. http://inversionconsulting.blogspot.com/2008/06/proe-vb-api-not-just-for-visual-basic.html Its a nice one to start from. Further to that I tried to take portions out of that eg, but some are not working as they are expected to! regards Joe. ---------------------------------------------- you can find some tips at... http://tipsfromjoe.blogspot.com ----------------------------------------------

The vbparam (vbparam.zip) example shows quite clearly how to access model parameters with the new VB API. Have simplified an example for you. This creates an array of parameter objects. Dim param As IpfcParameter Dim params As IpfcParameters Dim model As IpfcModel model = session.CurrentModel params = model.ListParams() For i = 0 To params.Count - 1 param = params(i) Next

Thanks Hugo, but this is exactly my problem. I too have seen that eg. I am using VBA (instead of VB). so there is slight difference between the two. But the actual problem is that the method ListParams() is not seems to be a method of the "model" at all. Complier cannot find that method at all. Also, when i checked documentation for the class IpfcModel, this method (ListParams) is not part of IpfcModel! Where as other parameters works.. like "model.Filename" Any idea why that might happen ? Thanks Joe

Joe OK, got it ListParams is not a method on the ipfcModel object but on the IpfcParameterOwner object. I quess this is relatet to the fact that features within a model can parameters so you have to tell who is the owner of the parameters. In this case its done by Set pOwner = mdl Hope this helps Hugo Private Sub CommandButton1_Click() Dim asynconn As New pfcls.CCpfcAsyncConnection Dim conn As pfcls.IpfcAsyncConnection Dim session As pfcls.IpfcBaseSession Dim mdl As pfcls.IpfcModel Dim pOwner As IpfcParameterOwner Set conn = asynconn.Connect("", "", ".", 5) Set session = conn.session Set mdl = session.CurrentModel Set pOwner = mdl For i = 0 To pOwner.ListParams.Count - 1 MsgBox ("Hello") Next conn.Disconnect (2) End Sub

Thanks a lot Hugo, that was impressive! I read in their documentation that IpfcModel is an owner. So I didnt think it this way! So is their sample program wrong ??? Anyway, thanks a lot.. You have opened a stream for me... Have a great weekend... Regards, Joe.

Joe The documentation for all the PTC API's pretty much sucks so we just have to do the best we can. It still puzzles me that PTC spends time and money on making API's without any user friendly documentation. What good is an API if nobody uses it? Anyways, i use visual studio.net and i tested the vbparam example without any problems (after fixing some minor syntax errors) Why the parameter owner is different from .net to vba is a puzzle to me (havent studied the code in detail) Created a tool for updating model parameters using weblink API and Javascript some time ago so i just had to go back and remember what i did

True Hugo. I agree with you. Thanks...

Hi Hugo, You have mentioned that you are using Visual Studio.net. so i guess you use vb.net. It seems that the whole documentation is only applicable for vb.net for vb scripting and vba, it might be complicated. this is from the documentation...

anonymous wrote:

"You can create another object of the appropriate type and assign it the object handle, and then call the required method

hello Mr Joe,

Can you help me how to get excel values in the current model. and how to regerate the model. I am so many time but the values are not set please give a sample program or procedure to help me. please help me

Top Tags