COM word.application, read checkbox value

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi there!

I've been trying for days to find a solution anywhere on the web to
this problem and I hope you might be able to sort me out.

I want to use PHP and COM to set and read values of MS Word form

I am able to read and write values to text-fields, but I cannot find
the solution for how to call a checkbox. :(

My code (for reading a form text field)...

$file = "";
$fnum = 5; // Arbitratry number of form field number

$word = new COM("word.application");
$word->Visible = 1;
$field = $word->ActiveDocument->Fields($fnum); // This is my problem
$data = $fields->Result;
$text = $data->Text;

So, I have been trying to find out what I should use instead of
CheckBox don't work and I haven't found any other clues.

Anyone who knows?


Patrik Birgerson

Re: COM word.application, read checkbox value

Isn't a checkbox also in ActiveDocument->Fields? Fields is not limited
to text-fields.

Re: COM word.application, read checkbox value

Well, I thought so too, but it doesn't seem so.
In the Word document there are several text-fields and checkboxes, and
the particular checkboxes I'm interested in lies between som

If I want to call the text-field right after the desired checkbox I use

If the checkbox was also callable by this method then I would get it
but then I get the text-field right before the checkboxes.

When I search for this problem I see that in other languages, such as
VB, C#, C++ and others, there are methods for calling checkbox.

So, how could I accomplish this with PHP?
Is there perhaps any way to enumerate the callable methods of the
word.application COM object?

Patrik Birgersson

Site Timeline