By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,526 Members | 2,189 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,526 IT Pros & Developers. It's quick & easy.

insert text, ms word document

P: n/a

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[1]->SaveAs("C:\\Path\\with inserted text.doc");
$word = null;

Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.