insert text, ms word document

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

    #1

    insert text, ms word document

    hi,

    i've hit a wall regarding php and ms word. what i want is to open a
    document containing bookmarks, insert text where the bookmarks are, and
    save.

    it's working, unless the bookmark is in the header part of the page (re
    header/ footer). in that case i get an error saying the bookmark
    wasn't found/ doesn't exist.

    anyone got any tip on how to get into the header part of a word
    document using php?

    the following, simple code works when bookmark is in the main part of
    document:

    $empty = new VARIANT();
    $word = new COM("word.appli cation") or die ("some explanation");
    $word->Documents->Open("C:\\Path \\Document with bookmark.doc");
    $word->Selection->GoTo(wdGoToBoo kmark, $empty, $empty, "bookmark") ;
    $word->Selection->TypeText("te xt to be inserted");
    $word->Documents[1]->SaveAs("C:\\Pa th\\with inserted text.doc");
    $word->Quit();
    $word = null;


    ingvald

Working...