Can't change column width in Custom Table

Can't change column width in Custom Table

Skadborg.NTI
Advocate Advocate
1,384 Views
9 Replies
Message 1 of 10

Can't change column width in Custom Table

Skadborg.NTI
Advocate
Advocate

If I place a Custom Table (General Table) on an idw, I can easily change column width in the GUI.

According to API-help Column.Width is read/write.

But if I try to set the width in iLogic I get an "unspecified error."

 

Dim oSheet = ActiveSheet.Sheet
Dim oCustomTable = oSheet.CustomTables.Item(1)
oCustomTable.Columns.Item(1).Width=3.0

What is wrong in above code?

0 Likes
Accepted solutions (1)
1,385 Views
9 Replies
Replies (9)
Message 2 of 10

dgreatice
Collaborator
Collaborator

Hi,

 

I try your code, but no error happen.

 

Are you already have custom table in active sheet?

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 3 of 10

Skadborg.NTI
Advocate
Advocate

File with table and rule attached

Error.png

0 Likes
Message 4 of 10

dgreatice
Collaborator
Collaborator

Hi,

 

im upgrade you code with input field.

 

Dim oSheet = ActiveSheet.Sheet
Dim oCustomTable = oSheet.CustomTables.Item(1)

i = InputBox("Colomn Number?", "Colomn Input")
If i = "" Then
Exit Sub
End If

DefaultWidth = (oCustomTable.Columns.Item(Val(i)).Width) * 10
j = InputBox("Width?", "Input Width", DefaultWidth)

oCustomTable.Columns.Item(Val(i)).Width = (Val(j) / 10)

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 5 of 10

Skadborg.NTI
Advocate
Advocate

Exact same error. Tried both 2017 and 2018, and on three different machines.

0 Likes
Message 6 of 10

dgreatice
Collaborator
Collaborator

try This,

 

Dim oDwgDoc as DrawingDocument

oDwgDoc = Thisapplication.ActiveDocument

Dim oSheet as Sheet

oSheet = oDwgDoc.ActiveSheet
Dim oCustomTable as CustomTable

oCustomTable = oSheet.CustomTables.Item(1)

i = InputBox("Colomn Number?", "Colomn Input")
If i = "" Then
Exit Sub
End If

DefaultWidth = (oCustomTable.Columns.Item(Val(i)).Width) * 10
j = InputBox("Width?", "Input Width", DefaultWidth)

oCustomTable.Columns.Item(Val(i)).Width = (Val(j) / 10)

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 7 of 10

Skadborg.NTI
Advocate
Advocate
Accepted solution

Hi,

 

Found the problem. It is caused by Windows Regional Settings. If I change to English(USA) it runs without problems.

Message 8 of 10

sellvakumarmech
Contributor
Contributor

it's working great, but I can't reduce the column width less the length of text(Column titel). when I use column width as 0.1. its returns as text length column width. could you please find a solution to this issue.

oCustomTable.Columns.Item(1).Width = .1

is there any possibility to kill the problem ASAP.

thanks in advance

Selvakumar v

0 Likes
Message 9 of 10

dgreatice
Collaborator
Collaborator

try with comma maybe?

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
Message 10 of 10

sellvakumarmech
Contributor
Contributor

Hey,

Thanks for your involvement in this.

Based on your idea, I add the comma to the title Text value. but it's now working. instead on that, I have used the new line command. so I believe, it reduces the width of the columns. if you have two or more word sentence as the title I suggest using the new line to reduce the column width as below.

    oTitles(0) = "BRAND" & vbCrLf & "NAME"
    oTitles(1) = "CATALOG NO."
    oTitles(2) = "PART" & vbCrLf & "DESCRIPTION"

maybe I wrong with your idea, kindly drive me in the right direction.

 

Looking for your solution...

Selvakumar V

0 Likes