R
R
Rxd2016-08-18 13:02:02
Visual Basic
Rxd, 2016-08-18 13:02:02

Why doesn't DoCmd.OutputTo close files in Access?

I ran into an interesting problem. When using DoCmd.OutputTo to export from Access to Excel, everything works fine, but after that the generated Excel files remain as if they were open. Those. the export was successful, but third-party programs cannot use them, because. these files seem to remain open. At the same time, if you open the file through Explorer, click "Save" and close, they become normal.

Set sklad = CurrentDb.OpenRecordset(StrSQL)
        If sklad.RecordCount > 0 Then
            With sklad
            For i = 1 To .RecordCount
                uPrais = !IP
                strOutputFile = "C:\" & !NP & ".xls"
                DoCmd.OutputTo acOutputQuery, "table_excel", "Excel97-Excel2003Workbook(*.xls)", 
                                            strOutputFile, False, "", 0, acExportQualityPrint
                .MoveNext
            Next i
            .Close
            End With
        End If
        Set sklad  = Nothing

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ananiev, 2016-08-18
@SaNNy32

Try putting DoEvents before/after DoCmd.OutputTo

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question