Skip to Content
author's profile photo Former Member
Former Member

Resize Word-Tables with ABAP

Hi,

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'
  EXPORTING
  #1 = 'normal.dot'.

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
  EXPORTING
  #1 = o_range
  #2 = '5'
  #3 = '3'.

GET PROPERTY OF o_selection 'Columns' = o_column.

CALL METHOD OF o_column 'SetWidth'
  EXPORTING
    #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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 12, 2005 at 03:41 PM

    Hello Christian,

    I made some changes to your code:

    ....
    CALL METHOD OF o_tables 'Add' = o_table
      EXPORTING
      #1 = o_range
      #2 = '5'
      #3 = '3'.
    
    GET PROPERTY OF o_table 'Columns' = o_columns.
    
    CALL METHOD OF o_columns 'Item'  = o_column
      EXPORTING
        #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.

    Regards,

    Juergen

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.