|
-
November 3rd, 1999, 09:55 AM
#1
Excel Object
Hi ,
I want to write to an existing Workbook.
If the Workbook is open by the time I do Workbook.Save ,
I'll get error.
My problem is I don't know how to detect if the Workbook is currently open
sothat I'll prompt users to close the Workbook before I make changes to it
Thanks
-
November 3rd, 1999, 05:52 PM
#2
Re: Excel Object
Use Spy++ (included in VS 6 Enterprise) to find the Class of Window for Workbook, then use FindWidow API finction. If return is 0, there is no open Workbook, otherwise either give a message or close Workbook using another API PostMessage. For MS Word it looks like this
Declare Function FindWindow& Lib "user32" Alias "FindWindowA" (byval lpClassName as string, byval lpWindowName as string)
Declare Function PostMessage& Lib "user32" Alias "PostMessageA" (byval hwnd as Long, byval wMsg as Long, byval wParam as Long, lParam as Any)
private Const WM_CLOSE = &H10
Dim lngReturn as Long
lngReturn = FindWindow("OpusApp", vbNullString)' OpusApp - Window Class for Word
lngReturn = PostMessage(lngHandle1, WM_CLOSE, 0, 0)
HTH
Vlad
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|