Skip to main content

[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?

[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?
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

[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?
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".

[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?
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".

[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?
Find attached the code for creating MailMerge with MS Word from ACUCOBOL-GT.

[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?
Find attached the Word.def file for use with the demo source provided in merge.zip