Lifelesspeople.com

 Forum FAQsForum FAQs  Knowledge BaseKnowledge Base  RulesRules   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   HostingHosting   RegisterRegister 
 DonateDonate   WikiWiki   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COM objects in MS Access 2007

 
Lifelesspeople.com Forum Index -> Help Wanted
Post new topic   This topic is locked: you cannot edit posts or make replies. View previous topic :: View next topic  
Author Message
Kovacs
Pepe El Contratado


Joined: 12 Jun 2005
Posts: 1402
Location: Leeds, UK / Guardamar Del Segura, España / Cayey, Puerto Rico

PostPosted: Wed Dec 19, 2007 3:03 pm    Post subject: COM objects in MS Access 2007 Reply with quote

So I'm doing another database project as required for one of my classes Sad

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


PostPosted: Wed Dec 19, 2007 3:42 pm    Post subject: Re: COM objects in MS Access 2007 Reply with quote

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. Wink

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."

Code:
ObjName.Quit


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

PostPosted: Wed Dec 19, 2007 3:45 pm    Post subject: Reply with quote

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


PostPosted: Wed Dec 19, 2007 3:58 pm    Post subject: Reply with quote

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

PostPosted: Wed Dec 19, 2007 4:07 pm    Post subject: Reply with quote

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! Silly
_________________
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
 
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    Lifelesspeople.com Forum Index -> Help Wanted All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Home | Hosting | News | Forum | Links | System Status | About | Archive | Donate ]
Powered by phpBB © 2001, 2002 phpBB Group
All trademarks and copyrights on this page are owned by their respective owners. Posts and comments are owned by the poster. Everything else © 2001 - 2007 Lifelesspeople.com