Steven
Steven

Reputation: 13769

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 = "excel C:\Documents and Settings\JohnDoe\Desktop\test.xls"
Run(myCommand)

Upvotes: 1

Views: 2355

Answers (4)

Gavin
Gavin

Reputation: 1

Do this:

Shell("excel C:\Documents and Settings\JohnDoe\Desktop\test.xls")

Saves you 2 other lines of code.

Upvotes: -1

B Pete
B Pete

Reputation: 946

Try this:

System.Diagnostics.Process.Start(myCommand)

Upvotes: 7

Anton
Anton

Reputation: 9961

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

Upvotes: 1

Paulo Santos
Paulo Santos

Reputation: 11587

See the Shell method

Upvotes: 1

Related Questions