Professional Documents
Culture Documents
Excel Export
Excel Export
Recordset)
On Error GoTo NoSave:
Dim FileNamePath As String
Dim xlAPP As Excel.Application
Dim xlWB As Excel.Workbook
Dim xlWS As Excel.Worksheet
Dim newrst As New ADODB.Recordset
Dim strWork As New ADODB.Stream
FileName = InputBox("What name do you wish to save the file as?" & Chr(10) &
"(Do not use '/', '\', '*', '?', or '|' in filename.)", "File Name")
If FileName <> "" Then
xlWS.SaveAs "c:\temp\" & FileName & ".xls"
FileNamePath = "c:\temp\" & FileName & ".xls"
Else
GoTo NoSave
End If
xlWS.Name = "Sheet1"
xlWB.Save
rst.Save strWork, adPersistADTG
newrst.Open strWork
Set strWork = Nothing
xlWS.Range("A1").Select
xlWS.QueryTables.Add newrst, xlWS.Range("A1")
xlWS.QueryTables(1).Refresh
xlWS.Activate
xlWB.Save
xlWB.Close
xlAPP.Quit
NoSave:
xlAPP.Quit
Set xlWS = Nothing
Set xlWB = Nothing
Set xlAPP = Nothing
End Function