Solved

Closing a window based on caption

Posted on 2004-08-11
2
344 Views
Last Modified: 2010-04-17
I need a clean way of closing a window based on the caption of the window.
For instance, if I want to close a window that has the word "DELETE" in it, how do I set that up?
0
Comment
Question by:robbperk
2 Comments
 
LVL 4

Accepted Solution

by:
cg_medistox earned 50 total points
ID: 11778886
Dim lHandle As Long
Dim lRez As Long

   Do
         ' Find the Menu window id.
      lHandle = FindWindow(vbNullString, "*Microsoft Outlook*")
         ' Kill it once
      If lHandle Then
         lRez = SendMessage(lHandle, WM_CLOSE, 0, 0)
         ' Kill it again in case didnt close
         lRez = SendMessage(lHandle, WM_DESTROY, 0, 0)
      End If 'lHandle
   Loop While lHandle <> 0

Change the Microsoft Outlook with what you need in there. This code is based on VB6 SP6
0
 
LVL 22

Expert Comment

by:cookre
ID: 11779860
You may need:

Private Const WM_DESTROY = &H02
Private Const WM_CLOSE = &H10
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now