From: Michael on
Hello,

I need to check and uncheck check box form field objects in a word document.

I got this far:

docFilename = 'TEST check box form.doc';
hdlActiveX = actxserver('Word.Application');
hdlActiveX.Visible = true;
trace(hdlActiveX.Visible);
hdlWordDoc = invoke(hdlActiveX.Documents, 'Open', docFilename);
h=invoke(hdlWordDoc.Bookmarks,'Item','Check1');
set(h.Range.FormFields.Shaded,0);

This works. It un-shades the checkbox.

These do not:


>> set(h.Range.FormFields(1),'Value',0)
??? Invoke Error: Unknown name or named argument

>> set(h.Range.FormFields(1),'Result',0)
??? Invoke Error: Unknown name or named argument


Thanks in advance.
From: Michael on
"
From: Yair Altman on
> >> set(h.Range.FormFields(1),'Value',0)
> ??? Invoke Error: Unknown name or named argument


try this:
set(h.Range.FormFields.item(1),'Value',0)

Yair Altman
http://UndocumentedMatlab.com
From: Michael on
Dear Mr. Altman,

Thank you for responding. I visit your website often.

This is a serious problem for me, I will have to rewrite my project in another language if I cannot solve it.

Unfortunately, your suggestion did not work for me.

Best,

Michael

P.S.,

>> set(h.Range.FormFields.item(1),'Value',0)
??? No appropriate method, property, or field item for class Interface.Microsoft_Word_12.0_Object_Library.FormFields.


>> h.Range.FormFields.item
??? No appropriate method, property, or field item for class Interface.Microsoft_Word_12.0_Object_Library.FormFields.


>> get(h.Range.FormFields)
Application: [1x1 Interface.Microsoft_Word_12.0_Object_Library._Application]
Creator: 1.2973e+009
Parent: [1x1 Interface.Microsoft_Word_12.0_Object_Library.Range]
Count: 1
Shaded: 1
From: Andy on
% Some sample code
% note: before running, create a word document with a check box in it

[fn,pn] = uigetfile('*.doc');
w = actxserver('Word.Application');
w.Visible = true;
d = w.Documents.Open([pn fn]);
ff=d.FormFields;
cb = ff.Item(1);
cb.CheckBox.Value = true; % <- Check Box is checked
cb.CheckBox.Value = false; % <- Check Box is unchecked