标题: 求助,如何使ACCESS导出到EXCEL后,单元格能自动调整宽度 [打印本页] 作者: daviee 时间: 2019-3-28 16:52 标题: 求助,如何使ACCESS导出到EXCEL后,单元格能自动调整宽度 平台的导出按钮代码
Private Sub cmdExport_Click()
On Error GoTo Err_Handler
Dim strSQL As String
Dim strExcelName As String
strSQL = Me.sfmSubForm.Form.RecordSource
'【导出语句】
If InStr(1, strSQL, "Select") = 0 Then strSQL = "select * from " & strSQL & ";"
If Me.sfmSubForm.Form.FilterOn = True Then
strSQL = Replace(strSQL, ";", "") '去掉;号
strSQL = "select * from (" & strSQL & ") as qryA where " & Me.sfmSubForm.Form.Filter
End If
'【导出结果】
strExcelName = Me.Caption & Format(Date, "_yyyymmdd")
gf_ExportToExcelBySql strSQL, strExcelName
Exit Sub
Err_Handler:
gf_MsgBox "", errError:=Err
End Sub