COM help -- SaveAs

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
bluesman333
Forum Commoner
Posts: 52
Joined: Wed Dec 31, 2003 9:47 am

COM help -- SaveAs

Post 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");
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you forgot to escape your backslashes. \t is a tab in a double quote string.
User avatar
bluesman333
Forum Commoner
Posts: 52
Joined: Wed Dec 31, 2003 9:47 am

is this your suggestion

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

neither \s nor \l transform into anything. \t is a tab. A tab cannot exist in a filename.
User avatar
bluesman333
Forum Commoner
Posts: 52
Joined: Wed Dec 31, 2003 9:47 am

still not working

Post by bluesman333 »

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

but it still doesn't work. can you see any other problems?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

try escaping all the backslashes.
Post Reply