Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP output to word problem

Status
Not open for further replies.

hyrogen

Programmer
Jul 10, 2003
60
GB
Hi,

I've managed to open up a word file and make edits from my php script, however Im having problems positioning where I make my edits. E.g. I've tried:

$word->Selection->MoveDown("Unit:=wdLine", "Count:=1");
$word->Selection->InsertAfter("*4*");
$word->Selection->MoveDown("Unit:=wdLine", "Count:=1");
$word->Selection->InsertAfter("*5");

But it just doesnt seem to have any effect, it just places them in the same place. Im not sure if its to do with the table that Ive got within word?. However, when I record a macro within word itself, the command:

Selection.MoveDown Unit:=wdLine, Count:=1

will work just fine.

Any ideas are much appreciated,
Cheers,
Jon
 
I finally found the solution, (typically straight after making this post) Just had to do something like:
$word->Selection->Tables(1)->Cell($rowPos,$colPos);

I am struggling with something else though:
$word->Selection->InsertFile("Name:=$handle");
This just does not want to seem to work at all. Its so I can get html inserted into the word doc with it all being formatted correctly. Again this works in vba.

Thanks if you can help!
 
are you supplying the whole path and file name to the InsertFile Com function? also are the permissions o nthe $handle file set ok?

interesting thought around permissions too: does the script user have to have read access to the $handle file or the user that is logged and instantiating word? worth an experiment or am i missing something obvious?
 
I've also sorted this problem, and again have another :)
I sorted the above problem by first changing to the correct directory rather than including the full path when including the file.

My problem now is when outputting to word; it seems of version 2003 if you click open straight away, word comes up with the error 'error opening file'. If you first save the generated word file and then click open, it works just fine. Any ideas why this might be? Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top