I'm pretty new to COBOL and programming and I'm having problems to create a word document from COBOL using ole object definitions.
I cant really find a good documentation for it, just some vba examples. I got some stuff to work - creating the document, writing text, formatting the text. Now I'm trying to add a header with an image to it - I found some vba code which I'm trying to translate:
With ActiveDocument.Sections(1).Headers _ .Item(wdHeaderFooterFirstPage).Range.InsertBefore "Sales Report"
I don't really understand it, because "headers" is not a property of sections, and also I never learned vba...
I'm using microfocus acubench 10.2.1
Current code:
working-storage section.
77 hFileSystemObject handle of FileSystemObject.
01 word-handles.
03 wrdApp handle of Application of word.
03 wrdDoc handle of Document of word.
03 sections handle of section of word.
03 myHeaderFooter handle of WdHeaderFooterIndex of word.
procedure division.
word-testing-section.
word-testing-010.
CREATE Application OF Word HANDLE IN WrdApp.
MODIFY WrdApp Documents::Add() GIVING wrdDoc.
MODIFY WrdApp @Visible = 1.
modify wrddoc @range = (0,100).
modify wrddoc @sections ::add() giving headersection.
modify wrddoc @sections(1)::@headers::
@item(wdHeaderFooterFirstPage)::@range::@insertbefore =
"Sales Report".
leads to:
D:\AcuReal\Source\testing2.cbl, line 52: Wrong number of parameters: 0 expected, 1 found
D:\AcuReal\Source\testing2.cbl, line 52: '@HEADERS' is not a property or method of 'CLASS @SECTIONS'
D:\AcuReal\Source\testing2.cbl, line 52: 'SECTIONS' must be a 'put' property or method of '@SECTIONS'
D:\AcuReal\Source\testing2.cbl, line 52: Undefined data item: @HEADERS
D:\AcuReal\Source\testing2.cbl, line 52: Verb expected, :: found
i also tried
modify WRDdoc @sections::@item(1)::
@headers::@item(@wdHeaderFooterPrimary)::@range::insertbefore"test".
D:\AcuReal\Source\testing2.cbl, line 60: Wrong number of parameters: 0 expected, 1 found
D:\AcuReal\Source\testing2.cbl, line 60: Wrong number of parameters: 0 expected, 1 found
and if i delete the parameters
D:\AcuReal\Source\testing2.cbl, line 58: Wrong number of parameters: 1 expected, 0 found
D:\AcuReal\Source\testing2.cbl, line 60: Wrong number of parameters: 1 expected, 0 found
Im pretty sure i have to use item twice with the wdHeaderFooterFirstPage parameter, but i have no idea why i get "wrong number of parameters" Really frustrating
How can I create a word document from COBOL using ole object definitions?