I'm opening an Excel template and checking the format of the template. If the format is not correct I want to send the appropriate message. I got it to work but it seems like a excessive use of try-catch. Is there a better way?
vb Code:
Try oExcel.Workbooks.Open(Filename:=m_inFile) Try oSht = CType(oExcel.Workbooks(1).Worksheets("control"), Excel.Worksheet) Catch ex As Exception End Try If oSht Is Nothing Then Throw New System.Exception("Invalid Template Format: No Control Sheet") End If oExcel.Visible = m_visible Catch ex As Exception MessageBox.Show("TemplateReader.Open: " & ex.Message.ToString) End Try




Reply With Quote