2011年計(jì)算機(jī)等級(jí)二級(jí)VB輔導(dǎo)知識(shí)技巧總結(jié)(26)(4)

字號(hào):


    xlDeleteApp.Worksheets(strSheetName).Delete
    xlDeleteApp.ActiveWorkbook.Save
    DeleteSheet = True
    Else
    DeleteSheet = False
    End If
    End If
    End Function
    ‘復(fù)制工作表
    Function CopySheet(ByVal strSrcSheetName As String, ByVal strSrcWorkBook As String, ByVal strTagSheetName As String, ByVal strTagWorkbook As String, xlCopyApp As Excel.Application) As Boolean
    Dim xlSrcBook As Excel.Workbook
    Dim xlTagBook As Excel.Workbook
    Dim ExcelSource As Excel.Worksheet
    Dim ExcelTarget As Excel.Worksheet
    Dim Result As Boolean
    If CheckFile(strSrcWorkBook) = False Or CheckFile(strTagWorkbook) = False Then
    Set ExcelSource = Nothing
    Set ExcelTarget = Nothing
    Set xlSrcBook = Nothing
    Set xlTagBook = Nothing
    CopySheet = False
    Exit Function
    Else
    Set xlSrcBook = xlCopyApp.Workbooks.Open(strSrcWorkBook)
    If strSrcWorkBook = strTagWorkbook Then
    If strSrcSheetName = strTagSheetName Then
    Set ExcelSource = Nothing
    Set ExcelTarget = Nothing
    Set xlSrcBook = Nothing
    Set xlTagBook = Nothing
    CopySheet = False
    Exit Function
    End If
    Set xlTagBook = xlSrcBook
    Else