Loading an Excel file saved in VB
The following is how I'm opening an Excel file in Form_Load when VB first starts:
Code:
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open(App.Path & "\test.xls")
Set xlSheetData = xlBook.Worksheets("input")
The VB program changes the cell values in test.xls. If the user wants to save the changes, I have a menu option:
Code:
Private Sub mnuSave_Click()
Dim xlFile As String
On Error Resume Next
comDialog.Filter = "Excel File (*.xls) | *.xls"
comDialog.FileName = "*.xls"
xlFile = comDialog.FileName
xlBook.SaveAs xlFile
End Sub
My primary question is - the next time the user runs the VB application, how can I modify the Form_Load code so that the saved "xlFile" is loaded instead of the default "test.xls"? Also, is it possible to show the Excel file name in the caption property of a Form?
Thanks