Page 1 of 1

COM help -- SaveAs

Posted: Sun Apr 03, 2005 5:00 pm
by bluesman333
new to COM... getting this error

Unable to lookup Document: Unknown name. in C:\site\word_test.php...

it has something to do with the SaveAs method

Code: Select all

$word = new COM("word.application"); 

$word->Visible = 1; 

//Open a new document 

$word->Documents->Open("C:\site\letterhead.doc"); 

//Write something

$word->Selection->Typetext("write something"); 
 

//Now save the document

$word->Document->SaveAs("C:\site\test.doc");

Posted: Sun Apr 03, 2005 5:03 pm
by feyd
you forgot to escape your backslashes. \t is a tab in a double quote string.

is this your suggestion

Posted: Sun Apr 03, 2005 5:23 pm
by bluesman333
but...

$word->Documents->Open("C:\site\letterhead.doc");

works just fine. without escaping. letterhead.doc opens without trouble. it's the saving part that isn't working.

Posted: Sun Apr 03, 2005 5:32 pm
by feyd
neither \s nor \l transform into anything. \t is a tab. A tab cannot exist in a filename.

still not working

Posted: Sun Apr 03, 2005 7:42 pm
by bluesman333
now i follow. $word->Document->SaveAs("C:\site\\test.doc");

but it still doesn't work. can you see any other problems?

Posted: Sun Apr 03, 2005 7:45 pm
by feyd
try escaping all the backslashes.