ms-wordpowerbuildercreateoleobject

OLE Object in PowerBuilder


Can anybody tell me how to set the value of a checkbox in a word document using OLE object?

I'm using form fields (dropdown and checkbox) in the Word document.

I am using PB 7.

Thanks!


Solution

  • I can't give you the exact PB syntax, but I can give you the Word object model syntax, which you shouldn't have any difficulty "translating".

    oDocument.FormFields(index).CheckBox.Value = true  'or false
    

    index can be either the position in the document (the nth form field in the text) or the name of the form field as a string ("Check1" for example).

    Note that it's not possible to use the macro recorder to get this syntax since the macro recorder won't run in a document protected as a form and it's not possible to change the checkbox value if the document is not protected as a form.