sBuffer, lBytesRead) Loop CloseHandle Proc.hProcess CloseHandle Proc.hThread CloseHandle hReadPipe Else ExecuteCommandLineOutput = "File or command not found" End If Else ExecuteCommandLineOutput = "CreatePipe failed. Error: " & Err.LastDllError & "." End If End If End Function Private Sub Command1_Click() ''''测试 ''''VBA.MsgBox ExecuteCommandLineOutput("ping www.sina.com.cn") VBA.MsgBox ExecuteCommandLineOutput("ping www.xxxx.com.cn", , 2) End Sub