COM word.application, read checkbox value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrik Birgersson

    COM word.application, read checkbox value

    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
    checkboxes.

    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 = "path.to.file.d oc";
    $fnum = 5; // Arbitratry number of form field number

    $word = new COM("word.appli cation");
    $word->Visible = 1;
    $word->Documents->Open($file);
    $word->Activate;
    $field = $word->ActiveDocume nt->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
    "Fields".
    CheckBox don't work and I haven't found any other clues.

    Anyone who knows?


    Regards,

    Patrik Birgerson

  • Sjoerd

    #2
    Re: COM word.applicatio n, read checkbox value

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

    Comment

    • Patrik Birgersson

      #3
      Re: COM word.applicatio n, 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
      text-fields.

      If I want to call the text-field right after the desired checkbox I use
      $word->ActiveDocume nt->Fields(53);

      If the checkbox was also callable by this method then I would get it
      with
      $word->ActiveDocume nt->Fields(52);
      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.
      (http://msdn2.microsoft.com/en-us/lib...ox(VS.80).aspx)

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


      Regards,
      Patrik Birgersson

      Comment

      Working...