我正在编写一个程序,它在应用程序的启动事件处理程序中启动一个Excel文件:
' Application.xaml.vb
Imports Microsoft.Office.Interop
Class Application
' Application-level events, such as Startup, Exit, and DispatcherUnhandledException
' can be handled in this file.
' Startup handler
Public Sub Application_Startup(sender As Object, e As StartupEventArgs) Handles Me.Startup
' Initialise Excel
Dim XLapp As Excel.Application
Dim XLwb As Excel.Workbook
Dim XLws As Excel.Worksheet
Dim XLra As Excel.Range
' File and worksheet are opened here, using inputprompt to query user for the right sheet.
End Sub
End Class
现在我的问题是,如何从MainWindow.xaml.vb访问这些变量(如XLws)?通常你会创建一个类的新对象,但这是否适用于应用程序的启动处理程序?如果是这样,我如何解决发件人和e参数错误?
我想要的是应用程序在启动时加载大型excel文件,然后在button_clicks上读取/写入它。