Sub refreshDataSet() Try Cursor.Current = Cursors.WaitCursor Write2myExcel() Finally Cursor.Current = Cursors.Default End Try closexlsfile() If openExcelfile(txtFilePath.Text) Then Try Cursor.Current = Cursors.WaitCursor RetrieveExcel() ValidateExcel() Finally Cursor.Current = Cursors.Default End Try Me.btnBrowse.Enabled = False End If End Sub Function openExcelfile(programmedfilename as string) As Boolean openExcelfile = False If programmedfilename <> "" Then Dim dlg As New OpenFileDialog() dlg.Filter = "Excel Macro Enabled Files|*.xlsm*|Excel Files|*.xls|Excel 2007 Files|*.xlsx|All Files|*.*" If dlg.ShowDialog() = DialogResult.OK Then txtFilePath.Text = dlg.FileName End If Else txtFilePath.Text = programmedfilename End If Me.ExcelWriteBtn.Enabled = txtFilePath.Text.Length > 0 Me.closexlsbtn.Enabled = txtFilePath.Text.Length > 0 Dim ExcelSheetName As String = "" objExcel = CreateObject("Excel.Application") wrkbks = objExcel.Workbooks objworkbook = wrkbks.Open(programmedfilename) openExcelfile = True End Function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)