Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » code completion for OLE/COM-objects?(Is it possible to get code coompletion for OLE/COM-objects?)
code completion for OLE/COM-objects? [message #657988] Fri, 04 March 2011 19:43 Go to next message
MarvinTheRobot  is currently offline MarvinTheRobot Friend
Messages: 1
Registered: March 2011
Junior Member
I'm looking for a way to get code completion for OLE/COM-objects.

example:
<?php
// start word
$word = new COM("word.application");

//show word
$word->Visible = 1;

//add empty document
$word->Documents->Add();

//insert some text
$word->Selection->TypeText("some text.");

//clear object
$word = null;
?>


It would be nice to get code completion for (in this case/example) the word object model.

I'm familiar with developing VBA 'scripts' for different applications, and I'm also familiar with PHP.

When using the Excel scripting editor it's possible to get code completion by referencing the type libraries of the other application you want to access via OLE/COM.

Is there a way to do this in Eclipse?
Re: code completion for OLE/COM-objects? [message #658021 is a reply to message #657988] Sat, 05 March 2011 05:52 Go to previous message
Toshihiro Izumi is currently offline Toshihiro IzumiFriend
Messages: 360
Registered: July 2009
Location: Japan
Senior Member
Definitely no.

You need definition files (like files under PHP Language Library) for code completion.

For example, (note that it is basic steps)

1. Create typeinfo file
Run this script and redirect output to file as wordobj.php.
<?php
$obj=new COM("word.application");
com_print_typeinfo($obj,"_Application");
com_print_typeinfo($obj,"Documents");
com_print_typeinfo($obj,"Selection");
// add all IDispatch you need
// but there are about 200 IDispatch...
?>

2. Edit wordobj.php
Add "<?php" tag.
Fix syntax error. (Selection::GoTo to Selection::_GoTo)
Add type declaration for properties.
> /* DISPID=6 */
> /* VT_PTR [26] */
> var $Documents;
to
> /* DISPID=6 */
> /* VT_PTR [26] */
> /**
> * @var Documents $Documents
> */
> var $Documents;
also
> /* DISPID=5 */
> /* VT_PTR [26] */
> var $Selection;
to
> /* DISPID=5 */
> /* VT_PTR [26] */
> /**
> * @var Selection $Section
> */
> var $Selection;
(other properties as well...)

3. Test
Move wordobj.php into your php project.
Edit your script, insert type declaration for pdt as
>/* @var $word _Application */
>$word = new COM("word.application");
>$word->
Test if code completion will work.

4. Create Library
Create folder for library somewhere and move typeinfo file.
Go to Preferences>PHP>PHP Libraries, Add new library, Add external folder.

5. Add Library to Project
Add the Library to PHP Include Path>Libraries.

(sorry for rough explanation)
Previous Topic:Anyone else who has problems editing large files?
Next Topic:Update PDT via http://www.eclipse.org/pdt/updates/ to 2.2.0
Goto Forum:
  


Current Time: Tue Oct 08 06:08:24 GMT 2024

Powered by FUDForum. Page generated in 0.04315 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top