VB.NET中的哪些函數只需要一個字符串參數並運行命令?它將像「開始」 - >「運行」對話框中的「確定」按鈕一樣工作。在VB.NET中運行命令
Dim myCommand as String
myCommand = "excel C:\Documents and Settings\JohnDoe\Desktop\test.xls"
Run(myCommand)
VB.NET中的哪些函數只需要一個字符串參數並運行命令?它將像「開始」 - >「運行」對話框中的「確定」按鈕一樣工作。在VB.NET中運行命令
Dim myCommand as String
myCommand = "excel C:\Documents and Settings\JohnDoe\Desktop\test.xls"
Run(myCommand)
試試這個:
System.Diagnostics.Process.Start(myCommand)
爲什麼這比殼牌更好? – Steven 2010-03-15 21:44:58
對於你的例子,可能沒有太大的區別。 Process.Start提供比shell更多的功能。 Process.Start函數可以返回一個Process對象。 Process對象包含有關進程的一些信息(例如.ProcessName),還允許您檢查項目是否仍在運行,並允許您終止進程。還有一個重載,允許您指定要運行的命令以及將文件打開爲兩個獨立的字符串,這可以簡化您的程序。 – 2010-03-15 22:06:43
可能是下一個嘗試:
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
excel = New Microsoft.Office.Interop.Excel.Application
wb = excel.Workbooks.Open("C:\Documents and Settings\JohnDoe\Desktop\test.xls")
excel.Visible = True
wb.Activate()
它會打開Excel和所選文檔
請執行以下操作:
Shell("excel C:\Documents and Settings\JohnDoe\Desktop\test.xls")
保存其他2行代碼。
你是指VBA還是VB.NET? Excel使用VBA。 – 2010-03-15 21:10:38