Running Macro in another app

spydog95

New Member
Joined
Apr 28, 2002
Messages
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
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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

Hope this helps.

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
This message was edited by NateO on 2002-04-29 13:43
 
Upvote 0

Forum statistics

Threads
1,214,613
Messages
6,120,515
Members
448,968
Latest member
Ajax40

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top