Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

fit column to data

Hi to Everybody,

I would like write a macro to fit colum to data.

I wrote:

sub fitColumn

set obj = ActiveDocument.GetSheetObject("CH157")

set cp = obj.GetProperties

set expr = cp.Expressions.Item(1).Item(0).Data.ExpressionVisual

expr.ColWidth = 800

obj.SetProperties cp

end sub

but it doesn'work

What's the problem?

Thanks in advance

1 Solution

Accepted Solutions
er_mohit
Master II
Master II

try this

sub x

set chart = ActiveDocument.GetSheetObject("CH02")

chart.SetPixWidth 0,100

chart.SetPixWidth 1,100

chart.SetPixWidth 2, 0

end sub

View solution in original post

5 Replies
marcus_sommer

Not applicable
Author

I have to fit column width no the window zoom

Not applicable
Author

I have a Pivot table, the code:

chart.SetPixWidths 0,w

chart.EqualPixWidths 1

doesn't work

Thank you

er_mohit
Master II
Master II

try this

sub x

set chart = ActiveDocument.GetSheetObject("CH02")

chart.SetPixWidth 0,100

chart.SetPixWidth 1,100

chart.SetPixWidth 2, 0

end sub

cmano
Creator
Creator

Hello Er

For reference i have a pivot table with 2 columns.

I use at edit module the below macro as you post :

 

sub x

set chart = ActiveDocument.GetSheetObject("CH82")

chart.SetPixWidth 0,200
chart.SetPixWidth 0,900

end sub

The problem is that it takes only the wider width and adjust the other...

Any suggestion?

Thank you for your time.