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 <gustav@xxxxxx> 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 jokeis like dissecting a frog: youjmertic@xxxxxxxxx understand it better,but the frog dies in the process." -Mark Twain