Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
I am new to the use of EXCEL VBA automation for CREO 2 Parametric, but as I saw in some online resources and from the most of the examples, all the reference are applicable for the most in VB.net using Visual studio.
Due to that, I did not find a workaround to translate thats example in excel, can anybody put me in the right way ?
The main problem at this stage is "F = ParamObjects.Item(i)" result in type mismatch
(Below an example of code that I tried):
Public Sub Off_H()
Dim asynconn As New pfcls.CCpfcAsyncConnection
Dim conn As pfcls.IpfcAsyncConnection
Dim session As pfcls.IpfcBaseSession
Dim oModel As pfcls.IpfcModel '<-------------changed
Dim compo As IpfcModelItem
Set conn = asynconn.Connect(Null, Null, ".", 5)
Set session = conn.session
Dim pOwner As pfcls.IpfcParameterOwner
Dim ParamObjects As CpfcParameters
Set oModel = session.CurrentModel
Set pOwner = oModel
Set ParamObjects = pOwner.ListParams()
Dim pro As pfcls.IpfcParameter
Dim pro_v As pfcls.IpfcParamValue
Dim a As String
Dim i As Integer
Dim ParamName As IpfcNamedModelItem
For i = 1 To (ParamObjects.Count - 1)
F = ParamObjects.Item(i)
d = ParamName.Name
Set ParName = d
Set pro_v = d.GetScaledValue()
Dim str(2) As String
Dim itm As ListObject
str(0) = ParName 'the name of the parameter
str(1) = pro_v.DoubleValue 'the value of the parameter¡ <Do something with the parameter here>
Next i
MsgBox ParamObjects(Param)
End Sub
Hello,
ParamObjects.Count Lbound is start 0
ParamName please use set accept IpfcNamedModelItem father Object
so:
Dim ParamName As IpfcNamedModelItem
Set ParamName As IpfcNamedModelItem
For i = 0 To (ParamObjects.Count - 1)
F = ParamObjects.Item(i)
d = ParamName.Name
Next
please try it