之前我实现了导出到指定的文件夹下面,但是怎么实现用户自己设置保存文件名和保存路径呢?Dim cn As New ADODB.Connection         '建立数据库连接
cn.Provider = "Microsoft.jet.oledb.4.0"
cn.ConnectionString = "D:\Program Files\Microsoft Visual Studio\VB98\motor.mdb"Dim Num As Integer         '获取马达编号
Num = FrmUser.cmb_Number.Text
Dim rs1 As New ADODB.Recordset
Dim strSql1 As String
strSql1 = "Select MotorNum,EleCurrent,Voltage,Speed,Temp,Periodth,NowTime From MotorPam Where MotorNum = " & Num & " Order by NowTime"
cn.Open
rs1.Source = strSql1
Set rs1.ActiveConnection = cn
rs1.LockType = adLockOptimistic
rs1.CursorLocation = adUseClient      '注意要用客户端的游标!
rs1.Open                              '一定要打开RecordSetIf rs1.RecordCount < 1 Then
MsgBox "没有记录,不能导出!", vbOKOnly + vbCritical, "错误提示"
Else
If Dir("C:\Excel", vbDirectory) = "" Then   '判断文件夹是否为空,若为空,则新建Excel文件夹
MkDir ("C:\Excel")
End If
If Dir("C:\Excel\MotorData.xls") <> "" Then   '判断该文件是否存在,若存在,则删除该文件
Kill ("C:\Excel\MotorData.xls")
End IfDim i As Integer
Dim j As Integer
Dim xlExcel As New Excel.Application
Dim xlBook As New Excel.Workbook
Dim xlSheet As New Excel.Worksheet
Set xlBook = xlExcel.Workbooks.Add
Set xlSheet = xlExcel.Worksheets.AddxlSheet.Cells.Columns(7).ColumnWidth = 20
xlSheet.Cells(1, 1) = "马达编号"
xlSheet.Cells(1, 2) = "电流"
xlSheet.Cells(1, 3) = "电压"
xlSheet.Cells(1, 4) = "转速"
xlSheet.Cells(1, 5) = "温度"
xlSheet.Cells(1, 6) = "周期"
xlSheet.Cells(1, 7) = "写入时刻"For i = 2 To rs1.RecordCount + 1
For j = 1 To rs1.Fields.Count
xlSheet.Cells(i, j) = rs1.Fields.Item(j - 1).Value
Next j
rs1.MoveNext
Next irs1.Close
cn.Close
CommonDialog1.ShowSave........
Set xlExcel = Nothing
MsgBox "导出成功!", vbOKOnly + vbInformation, "消息提示"
Exit Sub
End If其中省略号部分我就不会写了!请高手救我!