Windows API to check if currently selected object is of the outlook data type

bradyboyy88

Well-known Member
Joined
Feb 25, 2015
Messages
562
Is there a windows api function to check the data type of the last item focused on or clicked down on (this includes a dragged object) is of the outlook object type? For instance, if you clicked on your desktop icon to drag it highlights to show its been selected and when you select an email in outlook it highlights and unhighlights the desktop icon since its no longer in focus. Is there a way to check that the current focus selection is outlook related or even better a mailitem in the outlook object model?

Thanks!
 
Last edited:

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Currently I found this code which tells the active program window on the screen. Unfortunately, if outlook is put in front and you see the file explorer on the screen. You can select a file and drag it without making the file explorer the active window. Any ideas. I have included the code for reference. I want to get the active window for the actively selected object.

Rich (BB code):
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">ublicDeclareFunction GetForegroundWindow Lib"user32" _
    Alias"GetForegroundWindow"()AsLong
PublicDeclareFunction GetWindowText Lib"user32" _
    Alias"GetWindowTextA"(ByVal hwnd AsLong, _
    ByVal lpString AsString,ByVal cch AsLong)AsLong

Sub AAA()
    Dim WinText AsString
    Dim HWnd AsLong
    Dim L AsLong
    HWnd = GetForegroundWindow()
    WinText =String(255, vbNullChar)
    L = GetWindowText(HWnd, WinText,255)
    WinText = Left(WinText, InStr(1, WinText, vbNullChar)-1)
    Debug.Print L, WinText
EndSub

</code>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top