Dim ExistFile As String
DlgFile1.CancelError = True
DlgFile1.InitDir = App.Path + "\data"
DlgFile1.Filter = "Excel File(*.xls)|*.xls"
DlgFile1.DefaultExt = "xls"
DlgFile1.DialogTitle = "请输入新建立的数据文件名"
DlgFile1.ShowSave
ExistFile = Dir(DlgFile1.FileName)
If ExistFile <> "" Then
If MsgBox("文件已存在,是否覆盖?", vbOKCancel) = vbCancel Then Exit Sub
End If
DataFileName = DlgFile1.FileName
第二段
Set xlExcel = CreateObject("Excel.Application")
xlExcel.Workbooks.Open "e:\1.xls"
Set xlBook = xlExcel.Workbooks("1.xls")
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Cells(1, 1) = "输出数据"
xlSheet.Cells(2, 1) = "额定值和性能"
xlSheet.Cells(3, 1) = "额定功率PN"
xlSheet.Cells(3, 2).Value = Format(PN, "0.000")
xlSheet.Cells(4, 1) = "额定电压UN"
xlSheet.Cells(4, 2).Value = Format(UN, "0.000")
————————
Application.DisplayAlerts = False
xlBook.Close SaveChanges:=True
Application.DisplayAlerts = True
主要是想通过新建一个EXCEL文件,在把数据具体的写入到表格中打印
请各位帮忙啊,越详细越好