如何在VB中使用Excel打开xls文件

时间:2022-10-24 10:11:59

So, how can I tell the system to open the file for me? I've tried

那么,我如何告诉系统为我打开文件?我试过了

Shell(ExcelFilePath)

But an exception was thrown although the file path is from OpenFileDialog.FileOk

但是,虽然文件路径来自OpenFileDialog.FileOk,但抛出异常

So, I am trying to play with Excel.Application, is it possible to open the file with that?

所以,我正在尝试使用Excel.Application,是否可以用它打开文件?

2 个解决方案

#1


7  

This will open the file with Excel:

这将使用Excel打开文件:

Process.Start("EXCEL.EXE", """C:\Folder\file.xls""")

Being the second string the arguments for the process. See the MSDN Dcoumentation.

作为第二个字符串的过程参数。请参阅MSDN Dcoumentation。

#2


4  

try this

尝试这个

System.Diagnostics.Process.Start("FilePath")

it will open the file in an application associated with it.

它将在与之关联的应用程序中打开该文件。

#1


7  

This will open the file with Excel:

这将使用Excel打开文件:

Process.Start("EXCEL.EXE", """C:\Folder\file.xls""")

Being the second string the arguments for the process. See the MSDN Dcoumentation.

作为第二个字符串的过程参数。请参阅MSDN Dcoumentation。

#2


4  

try this

尝试这个

System.Diagnostics.Process.Start("FilePath")

it will open the file in an application associated with it.

它将在与之关联的应用程序中打开该文件。