PC Review


Reply
Thread Tools Rate Thread

Automate start VB in another instance of excel and continue _without_waiting for code to finish

 
 
bosenator@gmail.com
Guest
Posts: n/a
 
      22nd Feb 2009
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

 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      22nd Feb 2009
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


<(E-Mail Removed)> wrote in message
news:5136d76d-17ac-4ede-b9ab-(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
bosenator@gmail.com
Guest
Posts: n/a
 
      23rd Feb 2009
Hi Peter,
Thanks for taking time to take a look at this issue!

Actually, loading the adds in that part of the code takes 20 seconds,
but works fine..
I'm in need for inspiration on the 'xl.Run StartSub' line.
That line will run the vba code I selected, but it should only start
the code and continue with End If etc.. and not first wait 2 hours for
the 'StartSub' code to finish.

Hope this clearifies the problem a bit..

Regards,
Poniente



On 22 feb, 21:33, "Peter T" <peter_t@discussions> wrote:
> 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
>
> <bosena...@gmail.com> wrote in message
>
> news:5136d76d-17ac-4ede-b9ab-(E-Mail Removed)...
>
>
>
> > 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- Tekst uit oorspronkelijk bericht niet weergeven -

>
> - Tekst uit oorspronkelijk bericht weergeven -


 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      23rd Feb 2009
> xl.Run StartSub

I missed that part. Same suggestion as before.
Put a new routine in the same workbook as StartSub

Sub SartSubOnTime()
Application.OnTime Now, "StartSub"
End Sub

and do
xl.Run SartSubOnTime

I don't know if you will get the similar routines in different automated
instances to run asynchronously like that but give it a try. At the very
least all your code in your main routine should complete more quickly.

Regards,
Peter T


<(E-Mail Removed)> wrote in message
news:25524c0e-575a-44ab-93ec-(E-Mail Removed)...
Hi Peter,
Thanks for taking time to take a look at this issue!

Actually, loading the adds in that part of the code takes 20 seconds,
but works fine..
I'm in need for inspiration on the 'xl.Run StartSub' line.
That line will run the vba code I selected, but it should only start
the code and continue with End If etc.. and not first wait 2 hours for
the 'StartSub' code to finish.

Hope this clearifies the problem a bit..

Regards,
Poniente



On 22 feb, 21:33, "Peter T" <peter_t@discussions> wrote:
> 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
>
> <bosena...@gmail.com> wrote in message
>
> news:5136d76d-17ac-4ede-b9ab-(E-Mail Removed)...
>
>
>
> > 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- Tekst uit oorspronkelijk bericht niet weergeven -

>
> - Tekst uit oorspronkelijk bericht weergeven -



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Which code lines attached, keep me in current instance of Excel? EagleOne@discussions.microsoft.com Microsoft Excel Programming 0 10th Jun 2009 05:52 PM
how can I get excel to fill using a start and finish time =?Utf-8?B?ZGpqb20=?= Microsoft Excel Programming 1 7th Oct 2006 04:17 PM
Using Object model to start an instance of excel on another computer? P Microsoft Excel Programming 2 14th Apr 2006 09:34 PM
Set up Excel to start new instance for each new file opened. =?Utf-8?B?TWluaW1hbF9TdWJzZXQ=?= Microsoft Excel Misc 2 12th May 2005 01:36 AM
Automate PDF file creation in Excel code Ray Microsoft Excel Programming 5 17th May 2004 08:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:22 AM.