Com++ Word AND PHP?

Com++ Word AND PHP?

am 08.10.2007 14:46:00 von Gustav Wiberg

Hi
=20
I'm trying to run Word and save as a document in PHP. I have tested...
=20
$word =3D new COM("word.application");
//To see the version of Microsoft Word, just use $word->Version
echo "I'm using MS Word {$word->Version}";
//It's better to keep Word invisible
$word->Visible =3D 0;
//Creating new document
$word->Documents->Add();
//Setting 2 inches margin on the both sides
$word->Selection->PageSetup->LeftMargin =3D '2"';
$word->Selection->PageSetup->RightMargin =3D '2"';
//Setup the font
$word->Selection->Font->Name =3D 'Verdana';
$word->Selection->Font->Size =3D 8;
//Write some text
$word->Selection->TypeText("Hello, universe!");
//Save the document as DOC file
$word->Documents[0]->SaveAs("C:\hello2.doc");
// or use: $word->Documents[1]->SaveAs("C:htdocshello2.rtf",6); to save as =
RTF file
// or use: $word->Documents[1]->SaveAs("C:htdocshello2.htm",8); to save as =
HTML file
//And of course, quit Word
$word->quit();
//$word->Release();
$word =3D null;
//Give the user a download link
echo '';
?>


=20
On the line=20
$word -> $word->Documents[0]->SaveAs("C:\hello2.doc");
=20
I get the error:
Fatal error: Uncaught exception 'com_exception' with message 'Source: > Microsoft Word
Description: Den begärda medlemmen i en av sa=
mlingarna finns inte.' in C:\www\testword2.php:18 Stack trace: #0 C:\www\te=
stword2.php(18): unknown() #1 {main} thrown in C:\www\testword2.php on line=
18

I have setup a locally account which logs in to IIS and have set the rights=
in ComponentServices/Microsoft word.
The word-application seems to initiate but the save-as doesn't seem to work=
..

I'm using IIS on a windows XP. (I want to test locally before using on a pr=
oduction server)

What am I doing wrong?

Best regards
/Gustav Wiberg

=20

No virus found in this outgoing message.
Checked by AVG Free Edition.=20
Version: 7.5.488 / Virus Database: 269.14.4/1056 - Release Date: 2007-10-07=
18:12
=20

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Com++ Word AND PHP?

am 08.10.2007 15:20:18 von John Mertic

UGVyaGFwcyBjaGFuZ2luZyB0aGUgMCB0by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ICAgICAgICAgICAgICAgIkV4cGxhaW5pbmcgYSBq b2tlCmlzIGxpa2Ug
ZGlzc2VjdGluZyBhIGZyb2c6IHlvdQpqbWVydGljQGdtYWlsLmNvbSAgICAg ICAgICAgICAgICAg
ICAgICAgICAgICAgIHVuZGVyc3RhbmQgaXQgYmV0dGVyLApidXQgdGhlIGZy b2cgZGllcyBpbiB0
aGUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAg
ICAgIHByb2Nlc3MuIgoKICAgICAgICAgICAgICAgICAgICAgIC1NYXJrIFR3 YWluCg==

RE: Com++ Word AND PHP?

am 08.10.2007 15:24:00 von Gustav Wiberg

Hi

Nope it didn't seem to solve it.

Best regards
/Gustav Wiberg=20

-----Original Message-----
From: John Mertic [mailto:jmertic@gmail.com]=20
Sent: Monday, October 08, 2007 3:20 PM
To: Gustav Wiberg
Cc: php-windows@lists.php.net
Subject: Re: [PHP-WIN] Com++ Word AND PHP?

Perhaps changing the 0 to 1 in the line would fix it, namely:

$word->Documents[1]->SaveAs("C:\hello2.doc");

John

On 10/8/07, Gustav Wiberg wrote:
> Hi
>
> I'm trying to run Word and save as a document in PHP. I have tested...
>
> > $word =3D new COM("word.application");
> //To see the version of Microsoft Word, just use $word->Version
> echo "I'm using MS Word {$word->Version}";
> //It's better to keep Word invisible
> $word->Visible =3D 0;
> //Creating new document
> $word->Documents->Add();
> //Setting 2 inches margin on the both sides
> $word->Selection->PageSetup->LeftMargin =3D '2"';
> $word->Selection->PageSetup->RightMargin =3D '2"';
> //Setup the font
> $word->Selection->Font->Name =3D 'Verdana';
> $word->Selection->Font->Size =3D 8;
> //Write some text
> $word->Selection->TypeText("Hello, universe!");
> //Save the document as DOC file
> $word->Documents[0]->SaveAs("C:\hello2.doc");
> // or use: $word->Documents[1]->SaveAs("C:htdocshello2.rtf",6); to save a=
s RTF file
> // or use: $word->Documents[1]->SaveAs("C:htdocshello2.htm",8); to save a=
s HTML file
> //And of course, quit Word
> $word->quit();
> //$word->Release();
> $word =3D null;
> //Give the user a download link
> echo '';
> ?>
>
>
>
> On the line
> $word -> $word->Documents[0]->SaveAs("C:\hello2.doc");
>
> I get the error:
> Fatal error: Uncaught exception 'com_exception' with message 'Source:<=
/b> Microsoft Word
Description: Den begärda medlemmen i en av =
samlingarna finns inte.' in C:\www\testword2.php:18 Stack trace: #0 C:\www\=
testword2.php(18): unknown() #1 {main} thrown in C:\www\testword2.php on li=
ne 18
>
> I have setup a locally account which logs in to IIS and have set the righ=
ts in ComponentServices/Microsoft word.
> The word-application seems to initiate but the save-as doesn't seem to wo=
rk.
>
> I'm using IIS on a windows XP. (I want to test locally before using on a =
production server)
>
> What am I doing wrong?
>
> Best regards
> /Gustav Wiberg
>
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.488 / Virus Database: 269.14.4/1056 - Release Date: 2007-10-=
07 18:12
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--=20
--=20
John Mertic "Explaining a joke
is like dissecting a frog: you
jmertic@gmail.com understand it better,
but the frog dies in the
process."

-Mark Twain

No virus found in this outgoing message.
Checked by AVG Free Edition.=20
Version: 7.5.488 / Virus Database: 269.14.4/1056 - Release Date: 2007-10-07=
18:12
=20

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Com++ Word AND PHP?

am 08.10.2007 15:27:32 von John Mertic

QWxzbyB0cnkgZG91YmxpbmcgdXAgdGhlIGJhY2tzbGFzaCBvciB1c2luZyBh IGZvcndhcmQgc2xh
c2ggb24gV2luZG93cwoKJHdvcmQtPkRvY3VtZW50c1sxXS0+U2F2ZUFzKCJD OlxcaGVsbG8yLmRv
YyIpOwotLW9yLS0KJHdvcmQtPkRvY3VtZW50c1sxXS0+U2F2ZUFzKCJDOi9o ZWxsbzIuZG9jIik7
CgpBbHNvIGJlIHN1cmUgdGhlIHByb2Nlc3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gcHJvY2Vzcy4iCj4KPiAgICAgICAgICAgICAgICAgICAgICAgLU1hcmsg VHdhaW4KPgo+IE5v
IHZpcnVzIGZvdW5kIGluIHRoaXMgb3V0Z29pbmcgbWVzc2FnZS4KPiBDaGVj a2VkIGJ5IEFWRyBG
cmVlIEVkaXRpb24uCj4gVmVyc2lvbjogNy41LjQ4OCAvIFZpcnVzIERhdGFi YXNlOiAyNjkuMTQu
NC8xMDU2IC0gUmVsZWFzZSBEYXRlOiAyMDA3LTEwLTA3IDE4OjEyCj4KPgo+ Cj4KCgotLSAKSm9o
biBNZXJ0aWMKam1lcnRpY0BnbWFpbC5jb20KaHR0cDovL2ptZXJ0aWMud29y ZHByZXNzLmNvbQoK
IkV4cGxhaW5pbmcgYSBqb2tlIGlzIGxpa2UgZGlzc2VjdGluZyBhIGZyb2c6 IHlvdSB1bmRlcnN0
YW5kIGl0CmJldHRlciwgYnV0IHRoZSBmcm9nIGRpZXMKaW4gdGhlIHByb2Nl c3MuIiAtLU1hcmsg
VHdhaW4K

RE: Com++ Word AND PHP?

am 08.10.2007 15:42:00 von Gustav Wiberg

Hi!

Now I've almost got it... I've managed to startup Word... And get this text=
in the word-application...
I've tested without anonymous access. I guess it was something with the any=
nomous account that messed things up.


But I get this error now:

I'm using MS Word 11.0
Fatal error: Uncaught exception 'com_exception' with message 'Source: > Microsoft Word
Description: Den begärda medlemmen i en av sa=
mlingarna finns inte.' in C:\www\testword2.php:19 Stack trace: #0 C:\www\te=
stword2.php(19): unknown() #1 {main} thrown in C:\www\testword2.php on line=
19


Den begärda medlemmen i en av samlingarna finns inte. =3D Member in one o=
f the collections doesn't exist
The error still "points" at line where SaveAs-member is typed in.


/Gustav


-----Original Message-----
From: John Mertic [mailto:jmertic@gmail.com]=20
Sent: Monday, October 08, 2007 3:28 PM
To: Gustav Wiberg
Cc: php-windows@lists.php.net
Subject: Re: [PHP-WIN] Com++ Word AND PHP?

Also try doubling up the backslash or using a forward slash on Windows

$word->Documents[1]->SaveAs("C:\\hello2.doc");
--or--
$word->Documents[1]->SaveAs("C:/hello2.doc");

Also be sure the process has create file access to to the C: drive.

John

On 10/8/07, Gustav Wiberg wrote:
> Hi
>
> Nope it didn't seem to solve it.
>
> Best regards
> /Gustav Wiberg
>
> -----Original Message-----
> From: John Mertic [mailto:jmertic@gmail.com]
> Sent: Monday, October 08, 2007 3:20 PM
> To: Gustav Wiberg
> Cc: php-windows@lists.php.net
> Subject: Re: [PHP-WIN] Com++ Word AND PHP?
>
> Perhaps changing the 0 to 1 in the line would fix it, namely:
>
> $word->Documents[1]->SaveAs("C:\hello2.doc");
>
> John
>
> On 10/8/07, Gustav Wiberg wrote:
> > Hi
> >
> > I'm trying to run Word and save as a document in PHP. I have tested...
> >
> > > > $word =3D new COM("word.application");
> > //To see the version of Microsoft Word, just use $word->Version
> > echo "I'm using MS Word {$word->Version}";
> > //It's better to keep Word invisible
> > $word->Visible =3D 0;
> > //Creating new document
> > $word->Documents->Add();
> > //Setting 2 inches margin on the both sides
> > $word->Selection->PageSetup->LeftMargin =3D '2"';
> > $word->Selection->PageSetup->RightMargin =3D '2"';
> > //Setup the font
> > $word->Selection->Font->Name =3D 'Verdana';
> > $word->Selection->Font->Size =3D 8;
> > //Write some text
> > $word->Selection->TypeText("Hello, universe!");
> > //Save the document as DOC file
> > $word->Documents[0]->SaveAs("C:\hello2.doc");
> > // or use: $word->Documents[1]->SaveAs("C:htdocshello2.rtf",6); to save=
as RTF file
> > // or use: $word->Documents[1]->SaveAs("C:htdocshello2.htm",8); to save=
as HTML file
> > //And of course, quit Word
> > $word->quit();
> > //$word->Release();
> > $word =3D null;
> > //Give the user a download link
> > echo '';
> > ?>
> >
> >
> >
> > On the line
> > $word -> $word->Documents[0]->SaveAs("C:\hello2.doc");
> >
> > I get the error:
> > Fatal error: Uncaught exception 'com_exception' with message 'Source=
:
Microsoft Word
Description: Den begärda medlemmen i en a=
v samlingarna finns inte.' in C:\www\testword2.php:18 Stack trace: #0 C:\ww=
w\testword2.php(18): unknown() #1 {main} thrown in C:\www\testword2.php on =
line 18
> >
> > I have setup a locally account which logs in to IIS and have set the ri=
ghts in ComponentServices/Microsoft word.
> > The word-application seems to initiate but the save-as doesn't seem to =
work.
> >
> > I'm using IIS on a windows XP. (I want to test locally before using on =
a production server)
> >
> > What am I doing wrong?
> >
> > Best regards
> > /Gustav Wiberg
> >
> >
> >
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.5.488 / Virus Database: 269.14.4/1056 - Release Date: 2007-1=
0-07 18:12
> >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> --
> John Mertic "Explaining a joke
> is like dissecting a frog: you
> jmertic@gmail.com understand it better,
> but the frog dies in the
> process."
>
> -Mark Twain
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.488 / Virus Database: 269.14.4/1056 - Release Date: 2007-10-=
07 18:12
>
>
>
>


--=20
John Mertic
jmertic@gmail.com
http://jmertic.wordpress.com

"Explaining a joke is like dissecting a frog: you understand it
better, but the frog dies
in the process." --Mark Twain

No virus found in this outgoing message.
Checked by AVG Free Edition.=20
Version: 7.5.488 / Virus Database: 269.14.4/1056 - Release Date: 2007-10-07=
18:12
=20

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Com++ Word AND PHP?

am 09.10.2007 10:16:00 von Gustav Wiberg

Hi!

I solved it! With some further testing.. Couldn't find it anywhere on the n=
et, but I simply guessed...
So If someone is interested. This is how I did in Word 2003.

$doc =3D $word->Selection->Document;
$docName =3D "c:\\www\Useless test.doc";
$doc->SaveAs($docName);=20

/Gustav

-----Original Message-----
From: John Mertic [mailto:jmertic@gmail.com]=20
Sent: Monday, October 08, 2007 3:28 PM
To: Gustav Wiberg
Cc: php-windows@lists.php.net
Subject: Re: [PHP-WIN] Com++ Word AND PHP?

Also try doubling up the backslash or using a forward slash on Windows

$word->Documents[1]->SaveAs("C:\\hello2.doc");
--or--
$word->Documents[1]->SaveAs("C:/hello2.doc");

Also be sure the process has create file access to to the C: drive.

John

On 10/8/07, Gustav Wiberg wrote:
> Hi
>
> Nope it didn't seem to solve it.
>
> Best regards
> /Gustav Wiberg
>
> -----Original Message-----
> From: John Mertic [mailto:jmertic@gmail.com]
> Sent: Monday, October 08, 2007 3:20 PM
> To: Gustav Wiberg
> Cc: php-windows@lists.php.net
> Subject: Re: [PHP-WIN] Com++ Word AND PHP?
>
> Perhaps changing the 0 to 1 in the line would fix it, namely:
>
> $word->Documents[1]->SaveAs("C:\hello2.doc");
>
> John
>
> On 10/8/07, Gustav Wiberg wrote:
> > Hi
> >
> > I'm trying to run Word and save as a document in PHP. I have tested...
> >
> > > > $word =3D new COM("word.application");
> > //To see the version of Microsoft Word, just use $word->Version
> > echo "I'm using MS Word {$word->Version}";
> > //It's better to keep Word invisible
> > $word->Visible =3D 0;
> > //Creating new document
> > $word->Documents->Add();
> > //Setting 2 inches margin on the both sides
> > $word->Selection->PageSetup->LeftMargin =3D '2"';
> > $word->Selection->PageSetup->RightMargin =3D '2"';
> > //Setup the font
> > $word->Selection->Font->Name =3D 'Verdana';
> > $word->Selection->Font->Size =3D 8;
> > //Write some text
> > $word->Selection->TypeText("Hello, universe!");
> > //Save the document as DOC file
> > $word->Documents[0]->SaveAs("C:\hello2.doc");
> > // or use: $word->Documents[1]->SaveAs("C:htdocshello2.rtf",6); to save=
as RTF file
> > // or use: $word->Documents[1]->SaveAs("C:htdocshello2.htm",8); to save=
as HTML file
> > //And of course, quit Word
> > $word->quit();
> > //$word->Release();
> > $word =3D null;
> > //Give the user a download link
> > echo '';
> > ?>
> >
> >
> >
> > On the line
> > $word -> $word->Documents[0]->SaveAs("C:\hello2.doc");
> >
> > I get the error:
> > Fatal error: Uncaught exception 'com_exception' with message 'Source=
:
Microsoft Word
Description: Den begärda medlemmen i en a=
v samlingarna finns inte.' in C:\www\testword2.php:18 Stack trace: #0 C:\ww=
w\testword2.php(18): unknown() #1 {main} thrown in C:\www\testword2.php on =
line 18
> >
> > I have setup a locally account which logs in to IIS and have set the ri=
ghts in ComponentServices/Microsoft word.
> > The word-application seems to initiate but the save-as doesn't seem to =
work.
> >
> > I'm using IIS on a windows XP. (I want to test locally before using on =
a production server)
> >
> > What am I doing wrong?
> >
> > Best regards
> > /Gustav Wiberg
> >
> >
> >
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.5.488 / Virus Database: 269.14.4/1056 - Release Date: 2007-1=
0-07 18:12
> >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> --
> John Mertic "Explaining a joke
> is like dissecting a frog: you
> jmertic@gmail.com understand it better,
> but the frog dies in the
> process."
>
> -Mark Twain
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.488 / Virus Database: 269.14.4/1056 - Release Date: 2007-10-=
07 18:12
>
>
>
>


--=20
John Mertic
jmertic@gmail.com
http://jmertic.wordpress.com

"Explaining a joke is like dissecting a frog: you understand it
better, but the frog dies
in the process." --Mark Twain

No virus found in this outgoing message.
Checked by AVG Free Edition.=20
Version: 7.5.488 / Virus Database: 269.14.5/1058 - Release Date: 2007-10-08=
16:54
=20

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php