How to get an excel file to OPEN without saving it somewhere

I have this code and I want the Excel file to just open and not output it to somewhere.  How do I change my code to do that?

Private Sub cmdExport_ALLORGS_Click()
'On Error GoTo Err_cmdExport_ALLORGS_Click

 Dim username As String, stDocName As String, stFilename As String
    If MsgBox("Click YES to export all Allotments to Excel, NO to export current Allotment.", vbYesNo, "Export Options") = vbYes Then
        'stDocName = "QryRecapTest_ExcelOutputALL"
        stDocName = "Copy of Allot_Q"
    End If

        DoCmd.OutputTo acOutputQuery, "Copy Of Allot_Q", "Excel97-Excel2003Workbook(*.xls)", "", True, "", , acExportQualityScreen
 '   Exit Sub

 '   MsgBox Err.Description
  '  Resume Exit_cmdExport_ALLORGS_Click

End Sub

Open in new window

Jass SainiAsked:
Who is Participating?
PatHartmanConnect With a Mentor Commented:
I'm not going to write the code but you would need to use automation to Open Excel, create a new workbook, make it visible, and populate the rows.

Then the user would need to save it if he wanted to.

But the question is why?  What is wrong with simply using one line of code - TransferSpreadsheet to create the file?
Jass SainiAuthor Commented:
i could use the TransferSpreadSheet ...thank You
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.