Do you have a question? Post it now! No Registration Necessary. Now with pictures!
March 22, 2005, 8:57 am
rate this thread
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
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
$empty = new VARIANT();
$word = new COM("word.application") or die ("some explanation");
$word->Documents->Open("C:\Path\Document with bookmark.doc");
$word->Selection->GoTo(wdGoToBookmark, $empty, $empty, "bookmark");
$word->Selection->TypeText("text to be inserted");
$word->Documents->SaveAs("C:\Path\with inserted text.doc");
$word = null;