Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Include wildcards in window title script? 1

Status
Not open for further replies.

Turb

Technical User
Feb 11, 2003
154
US
I have this script to close a window based on it's name (no, I didn't write it. I'm not that familiar with VB):
Code:
Set objWord = CreateObject("Word.Application")
Set colTasks = objWord.Tasks

If colTasks.Exists("this window") Then
    colTasks("this window").Close
End If

objWord.Quit
Is there some way I can use a wildcard to select any window with a specific word in the title; like "*window"?

Any help would be appreciated! :)
 
You might want to take a look at using WMI to end a process. You could compare process names for inclusion of your criteria and shut down the process.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
markdmac,
Thank you for your response.

Ending whatever process was causing this was the first thing I thought of, but since there is no process (besides explorer.exe) running for this, that approach doesn't work.
The above vb script works, but unfortunately, I have found that what the window is named, is dependant on what the OS is and how it is configured. Thus the reason for the request for help in making this script work for a window name that has a common word within it.
 
Perhaps something like this ?
Set objWord = CreateObject("Word.Application")
Set colTasks = objWord.Tasks
For Each objTask In colTasks
If InStr(1, objTask.Name, "window", 1) Then
objTask.Close
Exit For
End If
Next
objWord.Quit

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,
Thank you!
Worked like a charm!
A star for you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top