Re: Fw: COM surgery
| From: | tg-php at gryffyndevelopment dot com | Date: | Tue, 16 Jan 2007 17:04:54 +0000 |
| Subject: | Re: Fw: COM surgery | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-27392@lists.php.net to get a copy of this message | ||
There's thousands of things you can access via COM. Windows uses it extensively. Every
application in Microsoft Office uses COM. I've used COM between Excel and MapPoint to generate
maps (and yeah, I created a PHP script to access MapPoint directly.. but it was just easier to do it
via Excel).
Check out some of the examples in the PHP documentation:
http://www.php.net/manual/en/ref.com.php
Also, if you want to mess around with COM, try loading up MS Word or Excel (I like Excel myself
since you can use the cells to output your data and keep it somewhat straight for debugging and
general display).
Also, MS Office apps have a fairly nice debugger that is aware of the COM references you've set
up so it will autocomplete methods and properties as you type (even give you lists). I found it
easier to sketch out what I needed in there first, then work on translating it to PHP.
Another tip... you won't just be dealing with methods (actions, 'verbs') and
properties (adjectives) but also objects will be returned (of various types) and collections (of
objects).
Here's an example from mappoint:
# Connect to MapPoint and define some objects
$comobjMapPoint = new COM("mappoint.application") or die("Unable to instantiate
mappoint");
$comobjMapPoint -> Activate();
$comobjMapPoint -> Visible = FALSE;
$mapobjActiveMap = $comobjMapPoint -> ActiveMap();
$routeobjActiveRoute = $mapobjActiveMap -> ActiveRoute();
Also.. you might find it helpful to search for the application you're trying to connect to and
the key words "object model", at least in the Microsoft world. Despite MS being kinda
dumb sometimes, the Excel and MapPoint object models online are actually really well documented.
http://msdn2.microsoft.com/en-us/library/wss56bz7(vs.80).aspx
http://msdn2.microsoft.com/en-us/library/aa723478.aspx
Hopefully that'll give you a good headstart. But if your quest was "what applications
can I connect to via COM", the answer is going to be too long to list.. You should figure out
what you WANT to connect to and see if it supports COM. Lots of stuff does.
Good luck!
-TG
= = = Original message = = =
----- Original Message -----
From: "gunawan" <wibisonog@ramsayhealth.co.id>
To: <php-windows@lists.php.net>
Sent: Tuesday, January 16, 2007 11:57 AM
Subject: COM surgery
> i read the com and interested using in my program..
> but the help (php manual chm) don't give what i need
> example :
> $word = new COM("word.application") or die("Unable to instantiate Word");
> echo "Loaded Word, version $word->Version\n";
>
> metods:
> $obj = new COM("Application.ID");
> what i want to build nextt is not a main problem right now, what i want to
> ask was about how many Aplication.id able to receive by this com
> i have only:
> 1. word.application
> 2. ADODB.Connection
> 3. excel.application
> are there any application.id ??
>
>
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.