Showing results for 
Search instead for 
Did you mean: 

Resize Word-Tables with ABAP

Former Member
0 Kudos


I have a Problem by creating a Word-Table using the OLE2-Interface!

I created the Table with 5 rows and 3 columns. Everything perfect

But now I want to Resize the first Column. My Code is the following:

CREATE OBJECT o_word 'Word.Application'.

SET PROPERTY OF o_word 'Visible' = '1'.

GET PROPERTY OF o_word 'Documents' = o_documents.
CALL METHOD OF o_documents 'Add'
  #1 = ''.

GET PROPERTY OF o_word 'ActiveDocument' = o_actdoc.
GET PROPERTY OF o_word 'Selection' = o_selection.

GET PROPERTY OF o_actdoc 'Tables' = o_tables.
GET PROPERTY OF o_selection 'Range' = o_range.

CALL METHOD OF o_tables 'Add' = o_table
  #1 = o_range
  #2 = '5'
  #3 = '3'.

GET PROPERTY OF o_selection 'Columns' = o_column.

CALL METHOD OF o_column 'SetWidth'
    #1 = '196.8'
    #2 = '0'.

Unfortunately nothing happened

Can anyone help me?

The VB Code to Set the Width of a column is:

Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=196.8, RulerStyle:=wdAdjustNone

View Entire Topic
0 Kudos

Hello Christian,

I made some changes to your code:

CALL METHOD OF o_tables 'Add' = o_table
  #1 = o_range
  #2 = '5'
  #3 = '3'.

GET PROPERTY OF o_table 'Columns' = o_columns.

CALL METHOD OF o_columns 'Item'  = o_column
    #1 = '1'.

SET PROPERTY OF o_column 'Width' = 24.

so you do not need to find an object, you just created again via "Selection"...

I managed to set the Width property, which worked, but unfortunatlly only in POINTS.

I assume the method <b>SetWidth</b> is not supported because of it's parameter types.

-> OLE2 is not a prefered interface anymore

If you find my answer useful, please don't forget the reward.



Former Member
0 Kudos

Hello Juergen,

thank you so much! It works and solved my Problem!

I have one more question...

Are you from Germany? The reason why I ask is the following:

I'm in my apprenticeship as a Software Engineerer and I have the assignment to develop a programm which creates an WORD Document with Data from SAP!

I havent't already found enough documentation about using the OLE2 Interface in SAP.

Perhaps you could give me some more Information about this topic or you have a tip where I can get Information about using the Word Methods and what parametertypes they need!

Thanks a lot and kind regards,

Christian Kremer