主题:求助,Excel中xlbook.Worksheets.add找不到方法或数据成员
Dim xls As Excel.application
Dim xlbook As Excel.Workbooks
Dim xlsheet As Excel.Worksheet
Dim i As Integer
cmmDlg.Filter = "Excel工作表(*.xls)|*.xls|所有文件(*.*)|*.*"
cmmDlg.DialogTitle = "请选择保存目录和Excel文件名"
cmmDlg.Action = 2
If Trim(cmmDlg.FileName) = "" Then
MsgBox "未保存数据", vbOKOnly, "提醒"
Exit Sub
End If
If Dir(cmmDlg.FileName) <> "" Then '此目录下如有同名文件给出提示,并作相应处理
If MsgBox("文件已存在,是否覆盖!", vbYesNo + vbQuestion, "提醒") = vbNo Then
MsgBox "未保存数据", vbOKOnly, "提醒"
Exit Sub
Else
Kill (cmmDlg.FileName) '删除文件
End If
End If
'************打开工作表***************
Set xls = New Excel.application
xls.Visible = True
Set xlbook = xls.Workbooks.Add
Set xlsheet = xlbook.Worksheets.Add '这里总是出现[color=FF0000]找不到方法或数据成员[/color]的错误
xlsheet.Name = "工程量汇总"
'*********************************
Dim xlbook As Excel.Workbooks
Dim xlsheet As Excel.Worksheet
Dim i As Integer
cmmDlg.Filter = "Excel工作表(*.xls)|*.xls|所有文件(*.*)|*.*"
cmmDlg.DialogTitle = "请选择保存目录和Excel文件名"
cmmDlg.Action = 2
If Trim(cmmDlg.FileName) = "" Then
MsgBox "未保存数据", vbOKOnly, "提醒"
Exit Sub
End If
If Dir(cmmDlg.FileName) <> "" Then '此目录下如有同名文件给出提示,并作相应处理
If MsgBox("文件已存在,是否覆盖!", vbYesNo + vbQuestion, "提醒") = vbNo Then
MsgBox "未保存数据", vbOKOnly, "提醒"
Exit Sub
Else
Kill (cmmDlg.FileName) '删除文件
End If
End If
'************打开工作表***************
Set xls = New Excel.application
xls.Visible = True
Set xlbook = xls.Workbooks.Add
Set xlsheet = xlbook.Worksheets.Add '这里总是出现[color=FF0000]找不到方法或数据成员[/color]的错误
xlsheet.Name = "工程量汇总"
'*********************************