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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing a Window

Status
Not open for further replies.

tinac99

Programmer
Jan 17, 2002
58
US
Hi,

I'm trying to close a window(Word Document) using the CloseHandle function. The function returns 0 and upon calling the GetLastError function, it returned 1813("The specified resource type cannot be found in the image file."). I can't make something out of it. Can anyone please give me more explanation regarding what this error means?

Thanks.

 
Hi,

I'm trying to close a window(Word Document) using the CloseHandle function. The function returns 0 and upon calling the GetLastError function, it returned 1813("The specified resource type cannot be found in the image file."). I can't make something out of it. Can anyone please give me more explanation regarding what this error means?

Thanks.
 
You can't close a window using CloseHandle.
Greetings,
Rick
 
Can anybody give me some leads how I can close a Window Word Document through API functions?

Thanks...
 
If you have a handle to the window then you could get the thread id by using GetWindowThreadProcessId. Maybe you can then post a WM_QUIT message to the thread.
Greetings,
Rick
 
CloseHandle() cannot close a window. Use SendMessage() with WM_CLOSE to close an application knowing the handle of its main window.

If you do not know the handle of the main window but only the process id of the running application, then you should use ExitProcess() to terminate that process.
 
Winac99 does not want to terminate the word application. He wants to close a document window.
quote: "I'm trying to close a window(Word Document)"
I don't think you can do that using the ordinary windows message interface.
Try to get a handle to the Word.Application object and use the com interface. It might be tricky to find out which document window you want to close when you have opened more than one document.
 
Add a reference to the &quot;Microsoft Word <version> Object Library&quot;

The code should look like this:

dim w as new Word.Application
dim d as Word.Document
det d = w.documents(&quot;YourFileName&quot;)
d.close
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top