Wednesday, July 17, 2013

Run VBA reports in Multiple Instances - Shell

Sub RunExcelMultiple(RecCnt)

    Dim lPid As Long, i As Long
    Dim sRemoteWbName As String, sExeName As String, sParams As String
    sExeName = "excel.exe"
    
    sRemoteWbName = """" & ActiveWorkbook.FullName & """"
    
    sParams = " /e" & " -!- " & " "
    
    If (RecCnt < 11) Then
      lPid = Shell(sExeName & sParams & sRemoteWbName, vbHide)
    Else
        For ShellInstance = 1 To Round(WorksheetFunction.Min(8, RecCnt / 4), 0)
            lPid = Shell(sExeName & sParams & sRemoteWbName, vbHide)
        Next ShellInstance
    End If
    
       

End Sub

No comments: