Creating an unwanted File with excel code? (1 Viewer)

NJudson

Who farted?
Local time
Today, 16:09
Joined
Feb 14, 2002
Messages
297
I've written some code to write some query results to an excel file but I'm getting an extra file saved that I don't want. I have my database located in "My Documents" but the pathname of the file that I'm trying to save to is different. When I run my code it saves to an excel file based on my desired destination path ok but it is also saving a file called RESUME.XLW in "My Documents" as well. I've taken this code from someone else before and used it in a different database and I don't have this problem. I'm not certain where in my code I would be creating this blasted RESUME.XLW file from. If anyone has any ideas or suggestions then I'd really appreciate it. Thanks.


Function ExportAndrewE911CoordinatinToExcel()
Dim dbs As DAO.Database
Dim qryAndrewTemplate As DAO.Recordset
Dim XL, XLW, i, j
Dim FileName As String
Dim PathName As String
Dim Destination As String

Set dbs = CurrentDb
Set XL = CreateObject("Excel.Application.9")
Set qryAndrewTemplate = dbs.OpenRecordset("SELECT * FROM qryAndrewTemplate")
PathName = "\\Rf-eng\c\Documents and Settings\chad\My Documents\XYPoint\"
FileName = "E911 Coordination (Andrew).xls"
Destination = PathName & FileName
Set XLW = XL.workbooks.Open(Destination)

XL.Visible = True
XLW.Application.screenupdating = False
XLW.Sheets("Site Data").Select
i = 2
XLW.Application.range("A2", "AG10000").Select
XLW.Application.selection.clearcontents
XLW.Application.range("A2").Select
Do Until qryAndrewTemplate.EOF
If qryAndrewTemplate.EOF Then Exit Do
For j = 1 To 54
XLW.Application.cells(i, j).Value = qryAndrewTemplate.Fields(j)
Next j
i = i + 1
qryAndrewTemplate.MoveNext
Loop
XLW.Application.screenupdating = True
XL.Save
XL.Quit
Set XL = Nothing
dbs.Close

End Function
 

Users who are viewing this thread

Top Bottom