Re: API Class Question
- From: "Jim Cone" <jim.coneXXX@xxxxxxxxxx>
- Date: Tue, 30 Oct 2007 07:50:44 -0700
Cory,
A different approach...
Word has a "Tasks" collection that represents all the tasks currently
running on the system. You can run code from Excel like this...
'--
Sub WhichOnes()
Dim objWord As Object
Dim objTasks As Object
Dim N As Long
Set objWord = CreateObject("Word.Application")
Set objTasks = objWord.Tasks
For N = 1 To objTasks.Count
Cells(N, 2).Value = objTasks(N).Name
Next 'N
Set objTasks = Nothing
objWord.Quit
Set objWord = Nothing
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)
<crferguson@xxxxxxxxx>
wrote in message
OK, so I'm pretty new to API's so forgive me if this is an idiot
question :-)
I'm putting together a class that uses API calls to user32 to
enumerate and list all running applications by their Title text. One
of the functions uses "AddressOf AnotherFunctionName" to accomplish
this. The code works fantastic in a module. However, when trying to
migrate this to a reusable class, the code crashes on that line with
an error of:
"Invalid use of AddressOf operator"
Looking in Help it says:
"You tried to use AddressOf with the name of a class method.
Only the names of Visual Basic procedures in a .bas module can be
modified with AddressOf. You can't specify a class method."
Well, shucks, that just popped my bubble of wanting to make this code
really efficient by keeping it in a class amongst some other utility
functions I've written. Seems I can only use it in a module instead.
My question is this: Is there a way to work around this in a class?
Here's my working module code that simply returns a Long greater than
zero if an app with all or part of the passed title is found to be
running:
-snip-
Of course the usage of this would be to pass a string to the only
public function FindWindowByTitle.
Thanks for any light that can be shed on this.
Cory
.
- Follow-Ups:
- Re: API Class Question
- From: crferguson@xxxxxxxxx
- Re: API Class Question
- References:
- API Class Question
- From: crferguson@xxxxxxxxx
- API Class Question
- Prev by Date: Re: Problem filtering by data >12/01/2002
- Next by Date: Re: Customizing menu buttons in Ecel 2007
- Previous by thread: Re: API Class Question
- Next by thread: Re: API Class Question
- Index(es):