![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Location: The LBC - Long Beach, CA
Posts: 4
|
I have a macro that runs a required macro in Word and then continues processing in Excel. The problem is that the Word macro takes about 30 minutes to run and I keep getting a message box that pops up in Excel saying that it's "waiting for another application to complete an OLE action."
I know about the WAIT function but it seems to only allow specification of a time or delta-time. What I'm looking for is some way to tell the Excel macro to wait until the Word macro is done. Thanks |
|
|
|
|
|
#2 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
The following uses an ontime method to test your PC every 3 seconds whether Word is open or closed. You can isolate your 'Post-Word' procedure and call the procedure in the instance Word has closed (in the event that your Word macro closes Word).
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public RunWhen As Date
Sub test()
Call StrtTimer
h = FindWindow("OpusApp", vbNullString) 'Word's Class Name
If h = 0 Then
Call StpTimer
MsgBox "Closed" 'Change this line to initiate your "Post-Word" procedure
Else:
End If
End Sub
Private Sub StrtTimer()
RunWhen = Now + TimeSerial(0, 0, 3)
Application.OnTime earliesttime:=RunWhen, procedure:="test", _
schedule:=True
End Sub
Private Sub StpTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, procedure:="test", _
schedule:=False
End Sub
_________________ Cheers, NateO [ This Message was edited by: NateO on 2002-04-29 13:43 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|