| Author |
Message |
Kovacs Pepe El Contratado

Joined: 12 Jun 2005 Posts: 1402 Location: Leeds, UK / Guardamar Del Segura, España / Cayey, Puerto Rico
|
Posted: Wed Dec 19, 2007 3:03 pm Post subject: COM objects in MS Access 2007 |
|
|
So I'm doing another database project as required for one of my classes
But I need to instantiate a program as a COM object so I can use the API for it. However, I am not 100% sure if this is the correct way to go about it.
If I use the following code in the VBA, would this be the correct way of instantiating the program as a COM object?:
| Code: | Dim ObjName As Object
Set ObjName = GetObject("C:\PATH\NAME.EXE") |
And then once this is done, I can access the API?
Then to destroy the object, I simply use this?:
| Code: | ObjName.Close
Set ObjName = Nothing |
Sorry if I use wrong terminology... _________________ I Love Rebecca More Than Anything In The World <3
Yo Amo A Rebecca Más Que Nada En El Mundo <3 |
|
| Back to top |
|
| |
LP-Harvey Forum Moderator
Joined: 23 Feb 2004 Posts: 3282
|
Posted: Wed Dec 19, 2007 3:42 pm Post subject: Re: COM objects in MS Access 2007 |
|
|
| Kovacs wrote: | If I use the following code in the VBA, would this be the correct way of instantiating the program as a COM object?:
| Code: | Dim ObjName As Object
Set ObjName = GetObject("C:\PATH\NAME.EXE") |
|
Yes. Just make sure it's an actual database (or whatever) and not an actual executable.
| Kovacs wrote: | | And then once this is done, I can access the API? |
Yes.
| Kovacs wrote: | Then to destroy the object, I simply use this?:
| Code: | ObjName.Close
Set ObjName = Nothing |
Sorry if I use wrong terminology... |
Well, you can't destroy an object considering all you're doing is accessing an alternate source via a new connection. So, you're actually, "Ending the connection."
That should do it. |
|
| Back to top |
|
| |
Kovacs Pepe El Contratado

Joined: 12 Jun 2005 Posts: 1402 Location: Leeds, UK / Guardamar Del Segura, España / Cayey, Puerto Rico
|
Posted: Wed Dec 19, 2007 3:45 pm Post subject: |
|
|
Ok... my bad then. I need to access the API of an actual program such as iTunes to retrieve temporary values at the time of request i.e. when the query which requires this value is run. For example, if I wanted the query to retrieve the play position of the current song... or something along those lines. _________________ I Love Rebecca More Than Anything In The World <3
Yo Amo A Rebecca Más Que Nada En El Mundo <3 |
|
| Back to top |
|
| |
LP-Harvey Forum Moderator
Joined: 23 Feb 2004 Posts: 3282
|
Posted: Wed Dec 19, 2007 3:58 pm Post subject: |
|
|
| Kovacs wrote: | | Ok... my bad then. I need to access the API of an actual program such as iTunes to retrieve temporary values at the time of request i.e. when the query which requires this value is run. For example, if I wanted the query to retrieve the play position of the current song... or something along those lines. |
Okay, cool. I can help slightly.
iTunes uses XML for listing songs and music tags. Since the listing uses tables, it's easy to import the XML file into Access.
| Quote: |
| Code: |
1: <dict>
2: <key>Track ID</key><integer>35</integer>
3: <key>Name</key><string>Landslide</string>
4: <key>Artist</key><string>Fleetwood Mac</string>
5: <key>Album</key><string>The Dance</string>
6: <key>Genre</key><string>Rock</string>
7: <key>Kind</key><string>Protected AAC audio file</string>
8: <key>Size</key><integer>4285488</integer>
9: <key>Total Time</key><integer>268283</integer>
10: <key>Disc Number</key><integer>1</integer>
11: <key>Disc Count</key><integer>1</integer>
12: <key>Track Number</key><integer>9</integer>
13: <key>Track Count</key><integer>17</integer>
14: <key>Year</key><integer>1997</integer>
15: <key>Bit Rate</key><integer>128</integer>
16: <key>Sample Rate</key><integer>44100</integer>
17: </dict>s
|
|
http://www.brainbell.com/tutor.....y_File.htm
Since the XML file is element based, importing is as easy as opening and closing an oledb connection. |
|
| Back to top |
|
| |
Kovacs Pepe El Contratado

Joined: 12 Jun 2005 Posts: 1402 Location: Leeds, UK / Guardamar Del Segura, España / Cayey, Puerto Rico
|
Posted: Wed Dec 19, 2007 4:07 pm Post subject: |
|
|
Uhm... they are all invariables though. I was wanting to access a temporary variable at a specific time. And iTunes was just a random example...
Never mind anyhow, this isn't something that is necessary for my project. Thanks for the help anyway. You can close this topic now big burd!  _________________ I Love Rebecca More Than Anything In The World <3
Yo Amo A Rebecca Más Que Nada En El Mundo <3 |
|
| Back to top |
|
| |
|
|
|