Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Software > Access General > How to force an...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 92553 of 97661
Post > Topic >>

How to force an application to be visible?

by Maury Markowitz <maury.markowitz@[EMAIL PROTECTED] > Aug 8, 2008 at 08:17 AM

I have a form in Access that calls a complex Excel VBA function to
generate a re****t, like this...

Public Sub RunRe****t()
On Error Resume Next
    Set oExcelApp = GetObject(, "Excel.Application")
    If Err <> 0 Then
        ' excel wasn't running, start it from code
        Set oExcelApp = CreateObject("Excel.Application")
    End If
On Error GoTo 0

    ret = oExcelApp.Application.Run("Re****tCreate.xla!BuildRe****t",
Me.Re****tId)
End Sub

The code works fine, and a re****t is generated. The problem is that if
Excel was not running when it was called, it opens in the background
somewhere and never becomes visible. On some people's machines a new
instance of Excel is opened whether or not it was already running, so
they can never see the resulting re****ts.

MS has a command called "AppActivate" that apparently claims to be
able to bring the app forward, but I'm at a loss how to actually use
it:

    AppActivate "Microsoft Excel"

results in "Run-time Error 5: Invalid procedure call or argument". The
do***ents SEEM to suggest this is because a window with that exact
name cannot be found, but if that is the case how could I possibly
know what the name is? It's creating a new workbook, it could be
called anything, Book1, Book2, Book73. The do***ents also state that
"it activates any application whose title string ends with Title", but
I have no idea how I could use that, Excel puts the book name AFTER
the title, so if I'm reading this correctly, that will never work
either!

I poked about on the 'net and found a function that seems to do the
same thing:

Public Function BringToFront(objApplication) As Boolean
    Dim lngRet As Long

    With objApplication
        lngRet = apiSetForegroundWindow(.hWndAccessApp)
        lngRet = apiShowWindow(.hWndAccessApp, SW_NORMAL)
        'the first call to ShowWindow doesn't seem to do anything
        lngRet = apiShowWindow(.hWndAccessApp, SW_NORMAL)
    End With
End Function

However, this results in "Run-time Error 438: Object doesn't sup****t
this property or method", which it re****ts for every line in the code.

Any ideas?

Maury
 




 4 Posts in Topic:
How to force an application to be visible?
Maury Markowitz <maury  2008-08-08 08:17:15 
RE: How to force an application to be visible?
=?Utf-8?B?SmltIFRob21saW5  2008-08-08 08:28:01 
Re: How to force an application to be visible?
Maury Markowitz <maury  2008-08-08 08:38:40 
Re: How to force an application to be visible?
=?Utf-8?B?SmltIFRob21saW5  2008-08-08 08:47:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Dec 4 22:27:07 CST 2008.