Results 1 to 6 of 6
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is 3rd Party App Running? (Excel 2000)

    We're working with a 3rd Party database app. At present, reports rely on an Excel Add-In - which will not load unless the app is already running. Is there a WinAPI call to test whether the app is already running (and so load the Add-In on starting Excel if relevant)?
    Gre

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Is 3rd Party App Running? (Excel 2000)

    I'll assume Excel does not have the Word equivalent to the Tasks object? That would give you what you want. But this article and code -- though rather wordy, IMHO -- should do it.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Is 3rd Party App Running? (Excel 2000)

    <img src=/S/thankyou.gif border=0 alt=thankyou width=36 height=24> I had looked at your "Is Word Running" thread before I posted. At the moment, we still have some Win 9x notebooks lurking about, so the winnowing may not be as extensive as one might wish.
    Gre

  4. #4
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Is 3rd Party App Running? (Excel 2000)

    For the record, in applying the suggested Q187913 code to parse out the name of the app to see if it is running, the unused portion of the space set aside for MAX_PATH torpedoes using Right(). Trim does not eliminate the surplus space. To allow for non-standard (e.g. multi-language) installations, the workaround used was to match the full path name using Left() and the length of the string produced by RegRead. (A reference to the Scripting Runtime is necessary.)
    Gre

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Is 3rd Party App Running? (Excel 2000)

    This probably is "too late now," but... As with many API calls and third party DLL functions, the GetModuleFileNameExA function does provide the "real" length of the string within the buffer, in this case, as the function return value. This is not crystal clear from Microsoft's relatively undocumented code, but there is a hint in this line:

    List1.AddItem Left(ModuleName, lRet)

    Unfortunately, you can never be sure which parameter is returning the string length without consulting the appropriate documentation.

    I think the reason Trim() does not work on strings returned from API calls is that Windows uses a C convention of terminating strings with a null (00 hex) character. VB/VBA does not interpret that as something it should trim, so does nothing. Using the above method with Left() is the most reliable way to trim them.

  6. #6
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Is 3rd Party App Running? (Excel 2000)

    I did actually try Left(ModuleName, lRet), but it choked. What actually turns out is that I had to use Mid(ModuleName, 1, lRet) due to some undetermined conflict in my code. Left(ModuleName, lRet) would only run if the Module was in something other than (my version of) personal.xls.
    Gre

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •