VB.NET Excel运行.XLA文件

时间:2015-07-25 18:51:41

标签: vb.net excel

我有以下代码。

我正在尝试调用EntFunc2.xla并将其加载到Excel1.xls中,但似乎没有成功。我可以知道如何直接通过VB.NET代码在Excel中运行xla文件吗?

   Dim xlApp As Excel.Application = Nothing
   Dim xlWorkBooks As Excel.Workbooks = Nothing
   Dim xlWorkBook As Excel.Workbook = Nothing
   Dim xlCells As Excel.Range = Nothing
   xlApp = New Excel.Application
   xlApp.DisplayAlerts = False
   xlWorkBooks = xlApp.Workbooks
   xlWorkBook = xlWorkBooks.Open("C:\Excel1.xls")
   xlApp.Visible = True
   xlApp.Run("P:\MASTER\EntFunc2.xla")

1 个答案:

答案 0 :(得分:0)

只需将XLA打开就像是普通的工作簿一样

xlWorkbooks.Open("P:\MASTER\EntFunc2.xla")