php-windows Digest 9 Oct 2007 08:16:52 -0000 Issue 3344

Topics (messages 28521 through 28531):

Re: Com++ Word AND PHP?
        28521 by: Gustav Wiberg
        28522 by: John Mertic
        28523 by: Stut
        28524 by: Gustav Wiberg
        28525 by: John Mertic
        28526 by: Gustav Wiberg
        28527 by: George Pitcher
        28528 by: Stut
        28529 by: Gustav Wiberg
        28531 by: Gustav Wiberg

Word Object Model...?
        28530 by: Gustav Wiberg

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
-----Original Message-----
From: George Pitcher [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 08, 2007 3:02 PM
To: Gustav Wiberg
Subject: RE: [PHP-WIN] Com++ Word AND PHP?

Gustav,

> I'm trying to run Word and save as a document in PHP. I have tested...
>
> <?php
> $word = 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 = 0;
> //Creating new document
> $word->Documents->Add();
> //Setting 2 inches margin on the both sides
> $word->Selection->PageSetup->LeftMargin = '2"';
> $word->Selection->PageSetup->RightMargin = '2"';
> //Setup the font
> $word->Selection->Font->Name = 'Verdana';
> $word->Selection->Font->Size = 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 = null;
> //Give the user a download link
> echo '<a href="hello2.doc">Download file as .doc</a>';
> ?>
>
>
>
> On the line
> $word -> $word->Documents[0]->SaveAs("C:\hello2.doc");
>
> I get the error:
> Fatal error: Uncaught exception 'com_exception' with message
> '<b>Source:</b> Microsoft Word<br/><b>Description:</b> 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 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 production server)
>
> What am I doing wrong?
>

I do this on my WinNT server - in fact its the only thing left stopping me
from moving to Linux!

My save line looks like:

$word->Documents[1]->SaveAs($fp2);

$fp2 is the path and name of the file.
The only difference being the '[1]' compared to your '[0]'.

Hope this helps.

Hi

No, I'm sorry it didn't help to change to [1]):

/Gustav



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
 


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
 

--- End Message ---
--- Begin Message ---
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 <[EMAIL PROTECTED]> wrote:
> Hi
>
> I'm trying to run Word and save as a document in PHP. I have tested...
>
> <?php
> $word = 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 = 0;
> //Creating new document
> $word->Documents->Add();
> //Setting 2 inches margin on the both sides
> $word->Selection->PageSetup->LeftMargin = '2"';
> $word->Selection->PageSetup->RightMargin = '2"';
> //Setup the font
> $word->Selection->Font->Name = 'Verdana';
> $word->Selection->Font->Size = 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 = null;
> //Give the user a download link
> echo '<a href="hello2.doc">Download file as .doc</a>';
> ?>
>
>
>
> On the line
> $word -> $word->Documents[0]->SaveAs("C:\hello2.doc");
>
> I get the error:
> Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> 
> Microsoft Word<br/><b>Description:</b> 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 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 
> 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
>
>


-- 
-- 
John Mertic                                        "Explaining a joke
is like dissecting a frog: you
[EMAIL PROTECTED]                              understand it better,
but the frog dies in the
                                                          process."

                      -Mark Twain

--- End Message ---
--- Begin Message ---
Gustav Wiberg wrote:
I do this on my WinNT server - in fact its the only thing left stopping me
from moving to Linux!

"COM functions are only available for the Windows version of PHP."

From http://php.net/com

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
Hi

Nope it didn't seem to solve it.

Best regards
/Gustav Wiberg 

-----Original Message-----
From: John Mertic [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 08, 2007 3:20 PM
To: Gustav Wiberg
Cc: [EMAIL PROTECTED]
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 <[EMAIL PROTECTED]> wrote:
> Hi
>
> I'm trying to run Word and save as a document in PHP. I have tested...
>
> <?php
> $word = 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 = 0;
> //Creating new document
> $word->Documents->Add();
> //Setting 2 inches margin on the both sides
> $word->Selection->PageSetup->LeftMargin = '2"';
> $word->Selection->PageSetup->RightMargin = '2"';
> //Setup the font
> $word->Selection->Font->Name = 'Verdana';
> $word->Selection->Font->Size = 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 = null;
> //Give the user a download link
> echo '<a href="hello2.doc">Download file as .doc</a>';
> ?>
>
>
>
> On the line
> $word -> $word->Documents[0]->SaveAs("C:\hello2.doc");
>
> I get the error:
> Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> 
> Microsoft Word<br/><b>Description:</b> 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 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 
> 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
>
>


-- 
-- 
John Mertic                                        "Explaining a joke
is like dissecting a frog: you
[EMAIL PROTECTED]                              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
 

--- End Message ---
--- Begin Message ---
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 <[EMAIL PROTECTED]> wrote:
> Hi
>
> Nope it didn't seem to solve it.
>
> Best regards
> /Gustav Wiberg
>
> -----Original Message-----
> From: John Mertic [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 08, 2007 3:20 PM
> To: Gustav Wiberg
> Cc: [EMAIL PROTECTED]
> 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 <[EMAIL PROTECTED]> wrote:
> > Hi
> >
> > I'm trying to run Word and save as a document in PHP. I have tested...
> >
> > <?php
> > $word = 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 = 0;
> > //Creating new document
> > $word->Documents->Add();
> > //Setting 2 inches margin on the both sides
> > $word->Selection->PageSetup->LeftMargin = '2"';
> > $word->Selection->PageSetup->RightMargin = '2"';
> > //Setup the font
> > $word->Selection->Font->Name = 'Verdana';
> > $word->Selection->Font->Size = 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 = null;
> > //Give the user a download link
> > echo '<a href="hello2.doc">Download file as .doc</a>';
> > ?>
> >
> >
> >
> > On the line
> > $word -> $word->Documents[0]->SaveAs("C:\hello2.doc");
> >
> > I get the error:
> > Fatal error: Uncaught exception 'com_exception' with message 
> > '<b>Source:</b> Microsoft Word<br/><b>Description:</b> 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 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 
> > 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
> >
> >
>
>
> --
> --
> John Mertic                                        "Explaining a joke
> is like dissecting a frog: you
> [EMAIL PROTECTED]                              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
>
>
>
>


-- 
John Mertic
[EMAIL PROTECTED]
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

--- End Message ---
--- Begin Message ---
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 
anynomous 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 '<b>Source:</b> 
Microsoft Word<br/><b>Description:</b> Den begärda medlemmen i en av 
samlingarna finns inte.' in C:\www\testword2.php:19 Stack trace: #0 
C:\www\testword2.php(19): unknown() #1 {main} thrown in C:\www\testword2.php on 
line 19


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


/Gustav


-----Original Message-----
From: John Mertic [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 08, 2007 3:28 PM
To: Gustav Wiberg
Cc: [EMAIL PROTECTED]
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 <[EMAIL PROTECTED]> wrote:
> Hi
>
> Nope it didn't seem to solve it.
>
> Best regards
> /Gustav Wiberg
>
> -----Original Message-----
> From: John Mertic [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 08, 2007 3:20 PM
> To: Gustav Wiberg
> Cc: [EMAIL PROTECTED]
> 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 <[EMAIL PROTECTED]> wrote:
> > Hi
> >
> > I'm trying to run Word and save as a document in PHP. I have tested...
> >
> > <?php
> > $word = 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 = 0;
> > //Creating new document
> > $word->Documents->Add();
> > //Setting 2 inches margin on the both sides
> > $word->Selection->PageSetup->LeftMargin = '2"';
> > $word->Selection->PageSetup->RightMargin = '2"';
> > //Setup the font
> > $word->Selection->Font->Name = 'Verdana';
> > $word->Selection->Font->Size = 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 = null;
> > //Give the user a download link
> > echo '<a href="hello2.doc">Download file as .doc</a>';
> > ?>
> >
> >
> >
> > On the line
> > $word -> $word->Documents[0]->SaveAs("C:\hello2.doc");
> >
> > I get the error:
> > Fatal error: Uncaught exception 'com_exception' with message 
> > '<b>Source:</b> Microsoft Word<br/><b>Description:</b> 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 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 
> > 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
> >
> >
>
>
> --
> --
> John Mertic                                        "Explaining a joke
> is like dissecting a frog: you
> [EMAIL PROTECTED]                              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
>
>
>
>


-- 
John Mertic
[EMAIL PROTECTED]
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. 
Version: 7.5.488 / Virus Database: 269.14.4/1056 - Release Date: 2007-10-07 
18:12
 

--- End Message ---
--- Begin Message ---
> Gustav Wiberg wrote:

Mis-attributed. This was in my reply to Gustav.

> > I do this on my WinNT server - in fact its the only thing left
> stopping me
> > from moving to Linux!
>
> "COM functions are only available for the Windows version of PHP."

My point exactly. When I am able to create a Word document in a Linux
version of PHP, I'll make the move.

Cheers

George

--- End Message ---
--- Begin Message ---
George Pitcher wrote:
Gustav Wiberg wrote:

Mis-attributed. This was in my reply to Gustav.

I do this on my WinNT server - in fact its the only thing left
stopping me
from moving to Linux!
"COM functions are only available for the Windows version of PHP."

My point exactly. When I am able to create a Word document in a Linux
version of PHP, I'll make the move.

My bad - the forwarded mail was confusing.

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
Hi!

I'm sorry but I did NOT write...
> Mis-attributed. This was in my reply to Gustav.

I DID NOT write:
>>> I do this on my WinNT server - in fact its the only thing left
>> stopping me
>>> from moving to Linux!
>> "COM functions are only available for the Windows version of PHP."



Just for you to know :-)

/Gustav

 

-----Original Message-----
From: Stut [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 08, 2007 3:49 PM
To: George Pitcher
Cc: Gustav Wiberg; [EMAIL PROTECTED]
Subject: Re: FW: [PHP-WIN] Com++ Word AND PHP?

George Pitcher wrote:
>> Gustav Wiberg wrote:
> 
> Mis-attributed. This was in my reply to Gustav.
> 
>>> I do this on my WinNT server - in fact its the only thing left
>> stopping me
>>> from moving to Linux!
>> "COM functions are only available for the Windows version of PHP."
> 
> My point exactly. When I am able to create a Word document in a Linux
> version of PHP, I'll make the move.

My bad - the forwarded mail was confusing.

-Stut

-- 
http://stut.net/

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
 

--- End Message ---
--- Begin Message ---
Hi!

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

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

/Gustav

-----Original Message-----
From: John Mertic [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 08, 2007 3:28 PM
To: Gustav Wiberg
Cc: [EMAIL PROTECTED]
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 <[EMAIL PROTECTED]> wrote:
> Hi
>
> Nope it didn't seem to solve it.
>
> Best regards
> /Gustav Wiberg
>
> -----Original Message-----
> From: John Mertic [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 08, 2007 3:20 PM
> To: Gustav Wiberg
> Cc: [EMAIL PROTECTED]
> 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 <[EMAIL PROTECTED]> wrote:
> > Hi
> >
> > I'm trying to run Word and save as a document in PHP. I have tested...
> >
> > <?php
> > $word = 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 = 0;
> > //Creating new document
> > $word->Documents->Add();
> > //Setting 2 inches margin on the both sides
> > $word->Selection->PageSetup->LeftMargin = '2"';
> > $word->Selection->PageSetup->RightMargin = '2"';
> > //Setup the font
> > $word->Selection->Font->Name = 'Verdana';
> > $word->Selection->Font->Size = 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 = null;
> > //Give the user a download link
> > echo '<a href="hello2.doc">Download file as .doc</a>';
> > ?>
> >
> >
> >
> > On the line
> > $word -> $word->Documents[0]->SaveAs("C:\hello2.doc");
> >
> > I get the error:
> > Fatal error: Uncaught exception 'com_exception' with message 
> > '<b>Source:</b> Microsoft Word<br/><b>Description:</b> 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 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 
> > 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
> >
> >
>
>
> --
> --
> John Mertic                                        "Explaining a joke
> is like dissecting a frog: you
> [EMAIL PROTECTED]                              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
>
>
>
>


-- 
John Mertic
[EMAIL PROTECTED]
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. 
Version: 7.5.488 / Virus Database: 269.14.5/1058 - Release Date: 2007-10-08 
16:54
 

--- End Message ---
--- Begin Message ---
Hi!
 
Where should I get any reference for Word Object Model for use with PHP. Is 
Microsofts documentation the only one available or is does anyone know some 
word-reference-parameters that are available for PHP-use... ?
The one I found is: 
http://msdn2.microsoft.com/en-us/library/tcyt0y1f(VS.80).aspx
 
 
Is there specific in Word that has to been installed for COM+ to work?
 
Best regards
/Gustav Wiberg
 
 
<?php
$word = 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 = true;
//Creating new document
$word->Documents->Add();
//Setting 2 inches margin on the both sides
$word->Selection->PageSetup->LeftMargin = '2"';
$word->Selection->PageSetup->RightMargin = '2"';
//Setup the font
$word->Selection->Font->Name = 'Verdana';
$word->Selection->Font->Size = 8;
//Write some text
//$word->Selection->TypeText("Hello, universe!");
$word->Selection->Documents[1]->Open("c:\\www\\test.doc");
//Save the document as DOC file
//$word->Documents[0]->SaveAs("test.doc");
//$word->Documents[1]->SaveAs("C:htdocshello2.rtf",6); 
// 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 = null;
//Give the user a download link
echo '<a href="hello2.doc">Download file as .doc</a>';
?>

--- End Message ---

Reply via email to