1. CJ Lai
  2. PowerBuilder
  3. Wednesday, 13 November 2019 14:36 PM UTC

Hi All

I have a MS Word OLE Checkbox question - I can not figure out a call to set a true/false value in a checkbox I place in a docx document.

I have googled the internet and all of the results did not help. Most of them use FormFields, which is not recognized in PB 2017. For example, https://bit.ly/2CCdsns

Not only did "FormFields" failed, but also property call such as 'Value', 'Checked', 'Clicked' failed as well.

Please help.

 

Thank you

CJ

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 13 November 2019 15:00 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi CJ,

there are different types of fields in Word.

That fields you may access using the "FormFields" property are the form fields from earlier word versions.

The new field types you may find using the "ContentControls" property.

If you use OLE controls you have to check the "InlineShapes" property.

 

You may try to get it work with Word Macros. If it works in Word you will also get it work in Powerbuilder.

HTH,

René

Comment
  1. CJ Lai
  2. Wednesday, 13 November 2019 16:34 PM UTC
I have a Word doc saved as "Microsoft Word 97 - 2003 Document (.doc)" using Office 365. I insert the checkbox by going Developer (menu item) > Legacy Tools > Check Box Form Field (in Legacy Forms).

I am not sure how to utilize "ContentControls" in my script for Word OLE (it is not recognized either the way I did it.)

  1. Helpful
  1. René Ullrich
  2. Thursday, 14 November 2019 07:01 AM UTC
I'm not sure what kind of Fields you have:

Try first this in a Word Macro to check what kind of fields you have,

MsgBox ActiveDocument.FormFields.Count

MsgBox ActiveDocument.ContentControls.Count

MsgBox ActiveDocument.InlineShapes.Count



If you have a FormField try this at next step:

If ActiveDocument.FormFields.Item("yourfieldname").Type = 71 Then

' 71 = wdFieldFormCheckbox

MsgBox ActiveDocument.FormFields.Item("Test").CheckBox.Value

End If



Use the Word Object Catalog the explore the object model. In my word version I get it using the F2 key in the Makro editor.
  1. Helpful
  1. CJ Lai
  2. Thursday, 14 November 2019 16:52 PM UTC
René

I am able to get the Count by using both FormFields.Count AND Bookmarks.Count. The count is correct.

Your script works for me. I was struggling with the syntax. All I needed was that '.CheckBox'.

Thank you so much!!

CJ
  1. Helpful
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.