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
bluesman333
Forum Commoner
Posts: 52 Joined: Wed Dec 31, 2003 9:47 am
Post
by bluesman333 » Sun Apr 03, 2005 5:00 pm
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");
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Apr 03, 2005 5:03 pm
you forgot to escape your backslashes. \t is a tab in a double quote string.
bluesman333
Forum Commoner
Posts: 52 Joined: Wed Dec 31, 2003 9:47 am
Post
by bluesman333 » Sun Apr 03, 2005 5:23 pm
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Apr 03, 2005 5:32 pm
neither \s nor \l transform into anything. \t is a tab. A tab cannot exist in a filename.
bluesman333
Forum Commoner
Posts: 52 Joined: Wed Dec 31, 2003 9:47 am
Post
by bluesman333 » Sun Apr 03, 2005 7:42 pm
now i follow. $word->Document->SaveAs("C:\site\\test.doc");
but it still doesn't work. can you see any other problems?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Apr 03, 2005 7:45 pm
try escaping all the backslashes.