Function OpenExcel(byval Excelpath, byval sheetname) 'As Excel.Application
On Error Resume Next
Dim ExcelApp
Dim ExcelWorkbook, GetSheet
Dim excelSheet 'As Excel.worksheet Set ExcelApp = CreateObject("Excel.Application") 'Create a new Microsoft Excel object
Set ExcelWorkbook = ExcelApp.Workbooks.Open(Excelpath)
ExcelApp.Visible = True
Set GetSheet = ExcelApp.Worksheets.Item(sheetname)
If Err.number = 0 Then
excelSheet =True
Else
excelSheet=False
End If
Set OpenExcel = GetSheet
End Function
No comments:
Post a Comment