Skip to Content
0

MailMerge in Word using SAP - Problem with locking variable fields in document header - OLE

Jul 03, 2017 at 06:16 AM

121

avatar image
Former Member

I'm developing a custom tool to use SAP to perform MailMerge on office Word. From a table in SAP I let the system populate the variables contained in the header of a Word template in order to print it. To do this we are using some standard OLE instructions, marking the document as final before to preview it, in order to make it not changeable and to keep variables' values.

But we noticed that this "trick" works only on Word versions until 2007. After this version is no longer possible to keep variables' values in header if the document is just "marked as final" (this is a problem due to the Word versions very common on the internet). So I tried to use the lock functionality (CTRL+F11) that should work always (and it works if I try on a Word document with variables in header). But someway instructions don't do their job through SAP! I paste here the whole instructions, I'm not an abaper but I hope you experts have any idea to overcome this issue.

Thank you in advance!

PS. I'm using SAP GUI 740 last patched and I already referred to several SAP notes (mainly 1645315 and 2100448)

-----------------------------------------------------------------------------------------------------------------------

CALL METHOD OF w_word 'ActiveWindow' = w_activewindow.
IF sy-subrc NE 0 .
MESSAGE i398(00) WITH 'Error ActiveWindow'.
LEAVE PROGRAM .
ENDIF .

CALL METHOD OF w_activewindow 'ActivePane' = w_activepane.
IF sy-subrc NE 0 .
MESSAGE i398(00) WITH 'Error ActivePane'.
LEAVE PROGRAM .
ENDIF .

CALL METHOD OF w_activepane 'View' = w_activeview.
IF sy-subrc NE 0 .
MESSAGE i398(00) WITH 'Error View'.
LEAVE PROGRAM .
ENDIF .

SET PROPERTY OF w_activeview 'SeekView' = '9'. " header view.
IF sy-subrc NE 0 .
MESSAGE i398(00) WITH 'Error SeekView = 9'.
LEAVE PROGRAM .
ENDIF .
*
* Selection.WholeStory
* Selection.Fields.Locked = True
CALL METHOD OF w_activepane 'Selection' = w_selection.
IF sy-subrc NE 0 .
MESSAGE i398(00) WITH 'Error Selection'.
LEAVE PROGRAM .
ENDIF .

* Selection.WholeStory
CALL METHOD OF w_selection 'WholeStory' = w_wholestory.
IF sy-subrc NE 0 .
MESSAGE i398(00) WITH 'Error WholeStory'.
LEAVE PROGRAM .
ENDIF .

CALL METHOD OF w_selection 'Fields' = w_fields.
IF sy-subrc NE 0.
ENDIF.

move 1 to ld_locked.
CALL METHOD OF w_fields 'Locked' = ld_locked.
IF sy-subrc NE 0.

ENDIF.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Matthew Billingham
Jul 03, 2017 at 06:18 AM
0

I did an ABAP controlled Word mail merge back in 2003. We used simple text replace, replacing tags like <<docno>> with the document number, for example, rather than variables.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thank you for sharing, I will consider this as a last chance maybe.
I've the feeling we are near to the solution, but something is still missing.

Any other idea regarding this issue?

0
Sandra Rossi Jul 03, 2017 at 06:26 PM
0

You should better ask the question in a non-ABAP forum, especially stackoverflow.

Share
10 |10000 characters needed characters left characters exceeded