Highlighted
Absent Member.
Absent Member.
1940 views

[archive] Foreign objects in Acucobol GT (5.x)

[Migrated content. Thread originally posted on 18 November 2002]

Since things are only starting, I'm posting in the main thread for now. Hope that's okay.

When using OLE automatition (or ActiveX), there doesn't seem to be a way to handle external (foreign) objects that are required as arguments for some OLE/ActiveX methods.

Example: When using Word Automation (OLE), I'd like to add some fields in a document. To do this, I need to use method Document.Selection.Fields.Add, this method required a range as first argument. The problem is that the range object doesn't seem to be willing to be held in a USAGE HANDLE variable.

Basically what I am trying to do is (by heart, so probably not compilable):

inquire word-app @Selection in word-sel.
inquire word-sel @Range in word-range.

modify word-sel @Fields::Add(word-range, 0, "REF somebookmark", 0).

That's the basic idea. The problem is that the range object doesn't seem to be willing to be casted to an ACUCobol handle or back. Any suggestions?
0 Likes
4 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Foreign objects in Acucobol GT (5.x)

Hi Leon,

What do you mean when you say you want to add some fields to a document?
What exactly are you trying to do?

If you just want to have some text dropped in the document you can use

modify word-app @Selection::TypeText("whatever you want").

Jim
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Foreign objects in Acucobol GT (5.x)

Hey Jim,

Thanx for the reply. What we are trying to do (what we did, got it working just yesterday) is establishing a interactive link between word documents (amongst others) and AcuCobol.

Just typing some text in a word document worked fine indeed, the problem was creating document-properties, bookmark, formfields and things like that. Next to this we wanted a way to execute small pieces to VBA-code inside the Office environment. Right now we'vew got most parts working.

The basic concept now is (not sure it compiles 😉

inquire word-sel @Range in range.
modify word-sel
@Formfields::Add(range, @wdFieldFormTextInput).

modify word-doc @Formfields::item(1) giving wfield.
modify word-doc @Protect(@wdAllowOnlyFormfields).

*Make some changes in word document and press enter here
accept omitted.

inquire Wfield @Result in wordval.
display wordval.

* Put something back in the field
modify Wfield @Result = "AcuCobol says hi".
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Foreign objects in Acucobol GT (5.x)

Find attached the code for creating MailMerge with MS Word from ACUCOBOL-GT.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Foreign objects in Acucobol GT (5.x)

Find attached the Word.def file for use with the demo source provided in merge.zip
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.