471,354 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

word and excel

Sam
I want php to start MS Word. I tried this but I receive an error:

1 <?php
2 $word = new COM("Word.Application") or die("Unable to instanciate Word");
3 $word->Visible=1
4 $word->Documents->Add("c:/test.doc");
5 $word->Quit();
6 $word->Release();
7 $word = null;
8 ?>

Error:
Warning: (null)(): Invoke() failed: Er is een uitzondering opgetreden. Source: Microsoft Word Description: De opslagruimte voor macro's kan niet worden geopend. in C:\Documents and Settings\sam\Mijn documenten\Werkmap\Sam\html\TMP1brqelb8k6.php on line 4

I tried the same with the Excel-Object:
In that case I don't receive an error but I cannot see the excel-workbook.

What am I doing wrong?
Jul 16 '05 #1
3 7225
There's nothing you can do if a client's MIME types are not successfully
set up in their browser to point application/msword to MS Word. But
since most Windows machines (and most Linux machines running OpenOffice)
do, you can use the following:

<?php
// We'll be outputting a Word Document
header("Content-type: application/msword");

// It will be called worddoc.doc
header("Content-Disposition: attachment; filename=worddoc.doc");

// The file source is in test.doc
readfile('test.doc');
?>

--
Sugapablo :: ru********@sugapablo.com
http://www.sugapablo.com | ICQ:902845

Jul 17 '05 #2
Sam
Actually, I want to do more than just open a Word-document.
I also want to write data to the bookmarks in my Word-document, etc.
It should be possible to do so with the Com-object
(If you go to the www.php.net site and search for 'com' in the function
list, you can see some examples).
One should be able to access the Word-document as from a VB-environment.
It just doesn't seem to work on my machine.
"Sugapablo" <ru********@sugapablo.com> schreef in bericht
news:vm************@corp.supernews.com...
There's nothing you can do if a client's MIME types are not successfully
set up in their browser to point application/msword to MS Word. But
since most Windows machines (and most Linux machines running OpenOffice)
do, you can use the following:

<?php
// We'll be outputting a Word Document
header("Content-type: application/msword");

// It will be called worddoc.doc
header("Content-Disposition: attachment; filename=worddoc.doc");

// The file source is in test.doc
readfile('test.doc');
?>

--
Sugapablo :: ru********@sugapablo.com
http://www.sugapablo.com | ICQ:902845

Jul 17 '05 #3
Sam wrote:
Actually, I want to do more than just open a Word-document.
I also want to write data to the bookmarks in my Word-document, etc.
It should be possible to do so with the Com-object
(If you go to the www.php.net site and search for 'com' in the function
list, you can see some examples).
One should be able to access the Word-document as from a VB-environment.
It just doesn't seem to work on my machine.


Please do not top post.

You could try to save Word files in HTML(XML)
format, then manipulating them will be easier. And
faster, too...Then, after changing, call the COM
object to turn it back into Word document.

--
Seks, seksić, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info { iWanToDie } WiNoNa ) (
http://szatanowskie-ladacznice.0-700.pl foReVeR( * )
Poznaj jej zwiewne kształty... http://www.opera.com 007
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

41 posts views Thread by Ruby Tuesday | last post: by
6 posts views Thread by Chris | last post: by
4 posts views Thread by Chris | last post: by
1 post views Thread by Bernd Muent | last post: by
3 posts views Thread by herman404 | last post: by
6 posts views Thread by Mark Rae | last post: by
7 posts views Thread by Peter | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.