Private Sub 生产一部格式_Click()
Dim ord_path, fname As String
Dim EXL As Object
fname = CStr(Date)
fname = "生产一部" & Replace(fname, "/", "")
ord_path = CurrentProject.Path & "\生产订单" & fname & ".xlsx"
'**************清空并生成生产一部订单导出表↓****************
DoCmd.SetWarnings False
DoCmd.RunSQL "delete * from 生产一部订单导出"
DoCmd.OpenQuery "qry生产一部订单导出"
DoCmd.SetWarnings True
'**************清空并生成生产一部订单导出表↑****************
ExportToExcelQueryTables "生产一部订单导出", fname
If Len(Dir(ord_path, vbDirectory)) > 0 Then
On Error GoTo 创建:
'MsgBox "文件" & CurrentProject.Path & "\报表\" & fileName & "已经存在"
Set EXL = GetObject(, "Excel.Application")
'Set xlWbk = xlApp.Workbooks.Open(CurrentProject.Path & "\报表\" & wshName)
EXL.Workbooks.Open (ord_path)
EXL.Visible = False
EXL.Visible = True
DoCmd.Close acForm, "frm订单导出格式选择"
Else
MsgBox "订单不存在,请生成后再打开"
End If
创建:
If Err = 429 Then
Set EXL = CreateObject("Excel.Application")
Resume Next
End If
End Sub
Dim ord_path, fname As String
Dim EXL As Object
fname = CStr(Date)
fname = "生产一部" & Replace(fname, "/", "")
ord_path = CurrentProject.Path & "\生产订单" & fname & ".xlsx"
'**************清空并生成生产一部订单导出表↓****************
DoCmd.SetWarnings False
DoCmd.RunSQL "delete * from 生产一部订单导出"
DoCmd.OpenQuery "qry生产一部订单导出"
DoCmd.SetWarnings True
'**************清空并生成生产一部订单导出表↑****************
ExportToExcelQueryTables "生产一部订单导出", fname
If Len(Dir(ord_path, vbDirectory)) > 0 Then
On Error GoTo 创建:
'MsgBox "文件" & CurrentProject.Path & "\报表\" & fileName & "已经存在"
Set EXL = GetObject(, "Excel.Application")
'Set xlWbk = xlApp.Workbooks.Open(CurrentProject.Path & "\报表\" & wshName)
EXL.Workbooks.Open (ord_path)
EXL.Visible = False
EXL.Visible = True
DoCmd.Close acForm, "frm订单导出格式选择"
Else
MsgBox "订单不存在,请生成后再打开"
End If
创建:
If Err = 429 Then
Set EXL = CreateObject("Excel.Application")
Resume Next
End If
End Sub