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

字號(hào):


    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
    Set xlTagBook = xlCopyApp.Workbooks.Open(strTagWorkbook)
    End If
    Set ExcelSource = xlSrcBook.Worksheets(strSrcSheetName)
    Set ExcelTarget = xlTagBook.Worksheets(strTagSheetName)
    ExcelSource.Select
    ExcelSource.Copy before
    ExcelTarget.Select
    ExcelTarget.Paste
    xlCopyApp.Application.CutCopyMode = xlCopy
    If strSrcWorkBook = strTagWorkbook Then
    xlTagBook.Save
    xlSrcBook.Save
    Else
    xlTagBook.Save
    End If
    Set ExcelSource = Nothing
    Set ExcelTarget = Nothing
    Set xlSrcBook = Nothing
    Set xlTagBook = Nothing
    CopySheet = True
    End If