By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,098 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,098 IT Pros & Developers. It's quick & easy.

Dev Ashish function not recognized. Need advice quick.

P: n/a
Hi folks,

I copied Dev Ashish's code below to a module in Access 2K. No mater
what I do, Access will not recognize the function. What have I
overlooked?

I know I'm going to feel like an idiot when I hear the answer.

All responses appreciated.
'***************** Code Start ***************
'This code was originally written by Dev Ashish.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code Courtesy of
'Dev Ashish
'
Private Const SW_HIDE = 0
Private Const SW_SHOWNORMAL = 1
Private Const SW_NORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_MAXIMIZE = 3
Private Const SW_SHOWNOACTIVATE = 4
Private Const SW_SHOW = 5
Private Const SW_MINIMIZE = 6
Private Const SW_SHOWMINNOACTIVE = 7
Private Const SW_SHOWNA = 8
Private Const SW_RESTORE = 9
Private Const SW_SHOWDEFAULT = 10
Private Const SW_MAX = 10

Private Declare Function apiFindWindow Lib "user32" Alias _
"FindWindowA" (ByVal strClass As String, _
ByVal lpWindow As String) As Long

Private Declare Function apiSendMessage Lib "user32" Alias _
"SendMessageA" (ByVal Hwnd As Long, ByVal Msg As Long, ByVal _
wParam As Long, lParam As Long) As Long

Private Declare Function apiSetForegroundWindow Lib "user32" Alias _
"SetForegroundWindow" (ByVal Hwnd As Long) As Long

Private Declare Function apiShowWindow Lib "user32" Alias _
"ShowWindow" (ByVal Hwnd As Long, ByVal nCmdShow As Long) As Long

Private Declare Function apiIsIconic Lib "user32" Alias _
"IsIconic" (ByVal Hwnd As Long) As Long

Function fIsAppRunning(ByVal strAppName As String, _
Optional fActivate As Boolean) As Boolean
Dim lngH As Long, strClassName As String
Dim lngX As Long, lngTmp As Long
Const WM_USER = 1024
On Local Error GoTo fIsAppRunning_Err
fIsAppRunning = False
Select Case LCase$(strAppName)
Case "excel": strClassName = "XLMain"
Case "word": strClassName = "OpusApp"
Case "access": strClassName = "OMain"
Case "powerpoint95": strClassName = "PP7FrameClass"
Case "powerpoint97": strClassName = "PP97FrameClass"
Case "notepad": strClassName = "NOTEPAD"
Case "paintbrush": strClassName = "pbParent"
Case "wordpad": strClassName = "WordPadClass"
Case Else: strClassName = vbNullString
End Select

If strClassName = "" Then
lngH = apiFindWindow(vbNullString, strAppName)
Else
lngH = apiFindWindow(strClassName, vbNullString)
End If
If lngH <> 0 Then
apiSendMessage lngH, WM_USER + 18, 0, 0
lngX = apiIsIconic(lngH)
If lngX <> 0 Then
lngTmp = apiShowWindow(lngH, SW_SHOWNORMAL)
End If
If fActivate Then
lngTmp = apiSetForegroundWindow(lngH)
End If
fIsAppRunning = True
End If
fIsAppRunning_Exit:
Exit Function
fIsAppRunning_Err:
fIsAppRunning = False
Resume fIsAppRunning_Exit
End Function
'******************** Code End ****************

Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"Lauren Wilson" <pr*****@nospam.com> wrote in message
news:8o********************************@4ax.com...
Hi folks,

I copied Dev Ashish's code below to a module in Access 2K. No mater
what I do, Access will not recognize the function. What have I
overlooked?


Lauren Wilson,

May I ask what you mean by "Access will not recognize"?
Sincerely,

Chris O.
Nov 13 '05 #2

P: n/a
On Thu, 3 Feb 2005 21:01:25 -0800, "Chris2"
<ra******************@GETRIDOF.luminousrain.com> wrote:

"Lauren Wilson" <pr*****@nospam.com> wrote in message
news:8o********************************@4ax.com.. .
Hi folks,

I copied Dev Ashish's code below to a module in Access 2K. No mater
what I do, Access will not recognize the function. What have I
overlooked?


Lauren Wilson,

May I ask what you mean by "Access will not recognize"?
Sincerely,

Chris O.


Thanks for responding Chris. I guess I was not clear enough on that.
By "not recognize" I mean that Intellisense will not display the
function options and when I compile, Access says it's an unrecognized
function. I hope that's what you want to know.

Do you have a clue what I'm doing wrong?

Thanks a lot Chris.

Nov 13 '05 #3

P: n/a

"Lauren Wilson" <pr*****@nospam.com> wrote in message
news:95********************************@4ax.com...
On Thu, 3 Feb 2005 21:01:25 -0800, "Chris2"
<ra******************@GETRIDOF.luminousrain.com> wrote:

"Lauren Wilson" <pr*****@nospam.com> wrote in message
news:8o********************************@4ax.com.. .
Hi folks,

I copied Dev Ashish's code below to a module in Access 2K. No mater what I do, Access will not recognize the function. What have I
overlooked?
Lauren Wilson,

May I ask what you mean by "Access will not recognize"?
Sincerely,

Chris O.


Thanks for responding Chris. I guess I was not clear enough on

that. By "not recognize" I mean that Intellisense will not display the
function options and when I compile, Access says it's an unrecognized function. I hope that's what you want to know.

Do you have a clue what I'm doing wrong?

Thanks a lot Chris.


Lauren Wilson,

I'm not sure I'm going to be of much aid, but here goes.

I'm running Win2K SP-3; Access 2K SP-3; JET 4.0 SP-8.

I launched Windows Media Player, ran an mp3.

In the Access Visual Basic Editor, I opened the Immediate Window and
typed therein:

? fisapprunning("Windows Media Player")

It reported True.

I closed WMP.

I ran the function again.

It reported False.

The code appears to be working just fine.
Sincerely,

Chris O.
Nov 13 '05 #4

P: n/a
Lauren Wilson wrote:
Thanks for responding Chris. I guess I was not clear enough on that.
By "not recognize" I mean that Intellisense will not display the
function options and when I compile, Access says it's an unrecognized
function. I hope that's what you want to know.

Do you have a clue what I'm doing wrong?

Thanks a lot Chris.


Perhaps you have to make the function Public for your form's
intellisense to pick it up. BTW, wasn't there a name similar to Lauren
Wilson in a Video Professor commercial?

James A. Fortune

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.