使用XLSXApp对象克隆XLSX文件的工作表
打开VB6工程,添加或者打开窗体,添加按钮

双击按钮,添加代码
Private Sub cmbCloneSheet_Click()
Dim DoXLSX As XLSXApp
Dim SheetName As String
Dim Error As String
Set DoXLSX = New XLSXApp
'打开XLSX文件
If DoXLSX.Open("Test1.xlsx", Error) = False Then
MsgBox Error
Set DoXLSX = Nothing
Exit Sub
End If
If DoXLSX.SheetExist("克隆表") = True Then
MsgBox "克隆表已存在!"
Set DoXLSX = Nothing
Exit Sub
End If
'克隆表
If DoXLSX.CloneSheet("Sheet1", "克隆表", Error) = False Then
MsgBox Error
Set DoXLSX = Nothing
Exit Sub
End If
DoXLSX.Save
'关闭XLSX文件
DoXLSX.Close
Set DoXLSX = Nothing
MsgBox "操作成功!"
End Sub
运行

Excel表的变化

被克隆表

克隆出的新表,与原表一模一样