0
我已創建3個Excel的實例和運行在每一個程序工作簿中運行在同一時間多個功能從另一個begining。我使用多核來提高性能。我試圖在不同的範圍內努力運行它。如何在VBA
的代碼示例
Sub Initiate()
Dim spath2 As String
Dim spath3 As String
Dim xlApp As Application
Dim xlFFQ1 As Application
Dim xlFFQ2 As Application
Dim xlFFQ3 As Application
Application.ScreenUpdating = False
Application.DisplayAlerts = False
spath1 = ThisWorkbook.Path & "\program1.xlsm"
spath2 = ThisWorkbook.Path & "\program2.xlsm"
spath3 = ThisWorkbook.Path & "\program3.xlsm"
Set xlApp1 = CreateObject("Excel.Application")
Set xlApp2 = CreateObject("Excel.Application")
Set xlApp3 = CreateObject("Excel.Application")
xlApp1.Workbooks.Open (spath1)
xlApp2.Workbooks.Open (spath2)
xlApp3.Workbooks.Open (spath3)
'those lines are independents and want to run each one without waiting the end of another. xlApp1/xlApp2/xlApp3 are different excel instances
xlApp1.Run "doMyStuffs"
xlApp2.Run "doMyStuffs"
xlApp3.Run "doMyStuffs"
如果事情不太清楚,只是說,我做的更好寫。
你想多線程,而不幸的,是不可能的VBA。 –
[在VBA多線程]的可能的複製(http://stackoverflow.com/questions/5721564/multi-threading-in-vba) –
每個工作簿在不同的情況下打開,我只需要做出「RUN」在每一箇中都不使用手動模式(打開每個工作簿並執行其宏)。 – Rajivdmo