overday Posted October 1, 2008 Share Posted October 1, 2008 Hi! The system I'm currently developing needs to read information from a Microsoft Project and save to a database. I'm trying to use COM, but no success. Here's a simple working code to create a word document: <?php $word = new COM("word.application") or die("Unable to load Word"); echo "Word loaded, version {$word->Version}\n"; $word->Documents->Add(); $word->Selection->TypeText("Test"); $word->Documents[1]->SaveAs("test.doc"); $word->Quit(); $word = null; ?> That works like a charm. Unfortunatelly, I couldn't find a single example of PHP accessing Project using COM. Then I tried this: <?php $project = new COM("msproject.application") or die("Unable to load Project"); ?> And a WINPROJ process was created. That was nice, but useless, because I get an error message when I try to use any method. <?php $project = new COM("msproject.application") or die("Unable to load Project"); $project->FileNew(""); ?> Results "Fatal error: Call to undefined method com::FileNew() in D:\FIGP\pms\upload.php on line 18". Even quitting, that is probably a method of all Office applications, gives the same error. <?php $project = new COM("msproject.application") or die("Unable to load Project"); $project->Quit(); ?> Results "Fatal error: Call to undefined method com::Quit() in D:\FIGP\pms\upload.php on line 18". I really need to read information from a MPP file, but I have no idea how to even create the project instance and create a new file. Could somebody help, please? ??? :'( Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted October 1, 2008 Share Posted October 1, 2008 If you can't find any documentation you could always play with http://us3.php.net/get_class_methods I've never used COM, but I'd suspect finding documentation would be easier than trying to figure things out with get_class_methods() Quote Link to comment Share on other sites More sharing options...
overday Posted October 2, 2008 Author Share Posted October 2, 2008 If you can't find any documentation you could always play with http://us3.php.net/get_class_methods I've never used COM, but I'd suspect finding documentation would be easier than trying to figure things out with get_class_methods() I think it doesn't work with COM <?php $excel = new COM("excel.application") or die("Unable to instantiate Excel"); echo "Loaded Excel, version {$excel->Version}\n"; echo "Class: ".get_class($excel)."\n"; $class_methods = get_class_methods(new COM("excel.application")); echo "Number of methods: ".count($class_methods)."\n"; foreach ($class_methods as $method_name) echo $method_name."\n"; $excel->Quit(); $excel = null; ?> Prints: Loaded Excel, version 11.0 Class: com Number of methods: 0 It DOES have methods, "$excel->Version" printed "11.0". Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.