View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Automate start VB in another instance of excel and continue _without_ waiting for code to finish

Not sure I quite follow but I guess the open event of one of those addins
(you are opening all the installed ones) goes on to do a lot of stuff. If
that's the case, in the relevant open event call that long code with an
OnTime macro

In passing,
xl.Workbooks.Open(ai.FullName).RunAutoMacros 1

Be careful doing that with all (unknown) addins with that in case the addin
is not the type that might have Auto_Open, eg a dll or xll.

Regards,
Peter T


wrote in message
...
Hi all,

Can anyone help me out with my last step in getting multiprocessing
automated?
I want to open several instances of excel and have each instance run
VB for about 2 hours. I guess I'm halfway:

The code below starts a new instance of excel, opens the specified
file, and starts the VB.
The problem is that it will now wait till the VB code is finished,
whereas I'd like it to continue starting up the other instances..

Can anyone help me out on this one?

Regards,
Poniente



Sub XlNewInstanceWithAddins(Optional PathFile As String, Optional
StartSub As String)
Dim xl As Object
Dim ai As Object

Dim PersPath As String

PersPath = Workbooks("Personal.xls").Path


Set xl = CreateObject("Excel.Application")

On Error Resume Next

For Each ai In Application.AddIns
If ai.Installed Then
xl.Workbooks.Open(ai.FullName).RunAutoMacros 1
End If
Next

xl.Workbooks.Open PersPath & "\Personal.xls"
xl.Visible = True

If PathFile < "" Then
xl.Workbooks.Open PathFile
If StartSub < "" Then
xl.Run StartSub
End If
End If

Set xl = Nothing

End Sub