Hi experts,
could some one help me with:
family.TableColumns.Add("DESCRIPTION", "Des", kStringType)
this code give me error in VBA; I want to add a new column in content centre.
(no problem with "family" object)
thanks
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Hi @capparottoQQZAF. I do not really interact with the Content Center much from code, but maybe I can help some with helping you understand what is going wrong, so that we can better understand how to solve the problem you are having. Since you are only showing that one line of code, I can only assume that the 'family' term being used is a variable that was declared as an Inventor.ContentFamily Type object, and that you have set a valid value to it. From that point, you are accessing the ContentFamily.TableColumns property, which represents a ContentTableColumns object, then trying to use its Add method. Can you tell us what the error message is saying, and what type of error it says it is? Sometimes those little details can help, if you know what to look for. The documentation says that the results of using this method will not take effect until after you have used the ContentFamily.Save method on that family. So, if you have already used this method before, but did not see an immediate change, then tried this method again, it may throw an error, because that column may already exist in memory, but you just have not saved it yet. Not sure what the case may be.
But there is one other detail...the family must be modifiable, or all these methods will fail. You can check that with ContentFamily.IsModifiable property.
Wesley Crihfield
(Not an Autodesk Employee)
Hi
this is th error: Object variable or With block variable not set
at the row: newcol = family.TableColumns.Add("DESCRIPTION", "Des", kStringType)
This is the code:
Sub Exec(family As ContentFamily)
Dim count As Integer
Dim newcol As ContentTableColumn
Dim expression As String
count = 0
For i = 1 To family.TableColumns.count
If family.TableColumns(i).InternalName = "Description [Project]" Then
expression = family.TableColumns(i).expression
count = 1
End If
Next
If count = 1 Then
MsgBox (family.DisplayName)
newcol = family.TableColumns.Add("DESCRIPTION", "Des", kStringType)
family.Save
Dim myFile As String
myFile = "C:\Users\massimo.a\Desktop\prova\vba.txt"
Open myFile For Append As #1
Write #1, family.DisplayName
Close #1
End If
End Sub
Can't find what you're looking for? Ask the community or share your knowledge.