VBA AppActivate function not working in Win XP

R

Raj Parulekar

Hi,

In my Access 2000 VBA code I am calling VBA's inbuilt AppActivate function,
which runs without a problem on Windows 2000 and/or Win 98 but is giving me
an "Invalid Procedure Call" error when the code is executed on a Win XP
Professional O/S. Does anyone know whether this is a known issue in the XP
operating system and what the resolution might be? Thanks...

Raj
 
M

Martin Seelhofer

Hi Raj
In my Access 2000 VBA code I am calling VBA's inbuilt AppActivate
function,
which runs without a problem on Windows 2000 and/or Win 98 but is giving
me
an "Invalid Procedure Call" error when the code is executed on a Win XP
Professional O/S. Does anyone know whether this is a known issue in the XP
operating system and what the resolution might be? Thanks...

Depends on what Application you are trying to activate. In case of Microsoft
Word, there might be a slight change in the structure of its window caption
(titlebar).
While earlier versions of Word (prior to 2K) started always with the string
"Microsoft Word", Word >=2K (with its Multi-TopLevel-Window-interface)
starts
with the active Document name. Therefore, you'll have to use an alternative
approach to activate the window e.g. by using the API-function FindWindow.
Try googling for it there should be plenty of ready to use solutions out
there...

Well, after going through your question again, I realize that you are
talking of a
problem with Windows XP which does not sound to be related to a specific
version of Office. But you might give the FindWindow-approach a try,
anyway...


Cheers,
Martin
 
R

Raj Parulekar

Hello Martin,

Thank you for your response. I have been trying to use the FindWindow API
function you suggested, but I need to know how to get either the window's
handle or the class name of the app I am trying to activate. Do you have any
suggestions for that.

Raj
 
M

Martin Seelhofer

Hi Raj
Thank you for your response. I have been trying to use the FindWindow API
function you suggested, but I need to know how to get either the window's
handle or the class name of the app I am trying to activate. Do you have
any
suggestions for that.

In case of Word, you might want to give "OpusApp" a try (Word's class
name)...
For other cases, Spy++ is a good tool to find out class names. Spy++ comes
with MS Visual Studio. A comparable freeware tool is SysTree++.

NB: Use vbNullString as the second parameter to FindWindow


Cheers,
Martin
 
R

Raj Parulekar

Thanks Martin,

Spy++ seems like a good idea, however, my app will not know the application
when opening files (since the files can be of any type tiff, doc, xls, pdf,
etc.) - hence I needed a programmatic way to determine the class name of the
app it will be using when it opens the document. Additionally do you know of
a url which lists all the class names of all the popular/major apps. I am
also particularly interested in the class name of the Kodak Imager
application. Thanks.

Raj
 
M

Martin Seelhofer

Hi Raj

Hm, I suddenly suspect me not to have properly understood
your problem. It seems to me now that the ShellExecute-API-
function does meet your goal more appropriately:
Const SW_SHOW = 1
Const SW_SHOWMAXIMIZED = 3

Public Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA"
_
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Sub RunYourProgram()
Dim RetVal As Long
On Error Resume Next
RetVal = ShellExecute(0, "open", "<full path to program>", "<arguments>",
_
"<run in folder>", SW_SHOWMAXIMIZED)
End Sub
taken from:
http://www.suodenjoki.dk/us/productions/articles/vbashellexecute.htm



Cheers,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top