Skip to Content

SAP OLE- Word doc text highlighting

Hi,

How can I fulfill below requirement.

screenshot-20190212-224325

I am using below code. What change can I do in this to achieve above requirement.

screenshot-20190212-230025.png

It's urgent. Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Can't you paste the code normally instead of image? (and use button CODE to display it correctly)

  • HI Sandra,

    In my word document created using SAP OLE currently the output is

    Expected output is

    I want the Yellow highlighting in the text.

    For this I have used below code but its not helping.

    *******************************************************************

    * Set Bold
    IF p_boldx NE space.
    SET PROPERTY OF g_font 'Bold' = p_bold.
    * SET PROPERTY OF g_font 'BackgroundPatternColor' = '65535'.
    * SET PROPERTY OF g_font 'HighlightColorIndex' = '65535'.
    ENDIF.
    * SET PROPERTY OF g_font 'Subscript' = '1'.
    * SET PROPERTY OF g_font 'DiacriticColor' = '65535'.

    GET PROPERTY OF g_font 'Interior' = g_color1.
    SET PROPERTY OF g_color1 'ColorIndex' = '6'.
    * Set Underline
    IF p_ulinex NE space.
    SET PROPERTY OF g_font 'Underline' = p_uline.
    ENDIF.

    * Set Alignment
    IF p_alignx NE space.
    SET PROPERTY OF g_parformat 'Alignment' = p_align. " 0-Left 1-Centered 2-Right
    ENDIF.

    * Value
    CALL METHOD OF
    g_selection
    'TypeText'

    EXPORTING
    #1 = p_text.

    ********************************************************************

    04xav.png (1.2 kB)
    zyiop.png (1.0 kB)
  • Follow
  • Get RSS Feed

1 Answer

  • Feb 12 at 07:04 PM

    Your piece of code looks correct based on the Word macro recorder, except the value 65535. The valid range goes from 0 (highlight off) to 18 (classic blue). Yellow is 7.

    Here is the VBA code obtained via the Word macro recorder:

    Selection.Range.HighlightColorIndex = wdYellow

    Object browser for color constant values:


    Add comment
    10|10000 characters needed characters exceeded