Run Command in VB.NET
What function in VB.NET simply takes a string parameter and runs a command? It would work just like the OK button in the Start -> Run dialog.
Dim myCommand as String
myCommand = "ex开发者_如何学运维cel C:\Documents and Settings\JohnDoe\Desktop\test.xls"
Run(myCommand)
Try this:
System.Diagnostics.Process.Start(myCommand)
See the Shell
method
May be try next:
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()
It will open Excel and selected document
Do this:
Shell("excel C:\Documents and Settings\JohnDoe\Desktop\test.xls")
Saves you 2 other lines of code.
精彩评论