Click to See Complete Forum and Search --> : How to close a Word Document with API
csantos
Jan 16th, 2000, 10:27 PM
I,
How can i close a word document with API like 'PostMessage' or other, without close Microsoft Word?
csantos
Jan 17th, 2000, 12:33 AM
Thanks, it works.
Just one more thing, using the ShellExecute how can i find the hwnd of the application i have launch.
Clunietp
Jan 17th, 2000, 11:04 AM
Here is an easier way, it does not use the API:
Add a reference to Microsoft Word 8/9.0 object library
Dim wd As Word.Application
'get object
Set wd = GetObject(, "Word.Application")
If wd Is Nothing Then
'error
MsgBox "Can't Find WORD!!!"
Else
'close document
wd.ActiveDocument.Close False
End If
Tom
csantos
Jan 17th, 2000, 11:13 AM
Thanks, but that way i now how to do.
I making an application that start the default application of a file. And for word i want to leave to word application open, i want just to close the document.
It's possible using the API?
Can someone help me or where can i found this type of information.
Clunietp
Jan 17th, 2000, 11:16 AM
My code finds the existing instance of MS Word and closes the active document, while leaving Word open. Is that not what you wanted?
csantos
Jan 17th, 2000, 11:20 AM
Yes, but, if i want to do the same for Excel i need another routine to treat that.
And i don't want that, I want with a simple routine treat word, excel... all office applications.
Thanks,
Clunietp
Jan 17th, 2000, 11:29 AM
You would probably have to use FindWindow, then EnumChildWindows, then sendmessage WM_CLOSE to the child windows.....that may not take care of the "SAVE DOCUMENT?" dialogs though....
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.