老师们, 我怎么用CAD vba打开excel 的文件窗口呢?
Sub sl ()Dim cc As CommonDialog
On Error Resume Next
cc.FileName = ""
cc.DialogTitle = "选择要导入的文件"
cc.Filter = "MicrosoftExcel 2003(*.xls)|*.xls|Microsoft Excel 2007(*.xlsx)|*.xlsx"
cc.ShowOpen
If cc.FileName = "" Then Exit Sub
End Sub
就是这个,第一个窗口 ??? 急求? 在线等吧???? Sub sl ()
'Dim cc As CommonDialog
On Error Resume Next
cc.FileName = ""
cc.DialogTitle = "选择要导入的文件"
cc.Filter = "MicrosoftExcel 2003(*.xls)|*.xls|Microsoft Excel 2007(*.xlsx)|*.xlsx"
cc.ShowOpen
If cc.FileName = "" Then
Exit Sub
Else
Dim ExcelApp As Object
Dim Workbooks As Object
Set ExcelApp = CreateObject("Excel.Application")
If Err Then
MsgBox Err.Number & ":" & Err.Description '打开失败
Exit Sub
End If
ExcelApp.Visible = True '显示Excel
Set Workbooks = ExcelApp.Workbooks
Workbooks.Open cc.FileName
End If
End Sub 老师, 本身cc 的值就等于空的
If cc.FileName = "" Then
Exit Sub这就直接结束了, !
启用Dim cc As CommonDialog就行了呗, If cc.FileName = "" Then是控制没有选择打开文件时退出的
页:
[1]