• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 109
  • Last Modified:

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"
    Else
        stDocName = "Copy of Allot_Q"
    End If
    

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

'Err_cmdExport_ALLORGS_Click:
 '   MsgBox Err.Description
  '  Resume Exit_cmdExport_ALLORGS_Click
    

End Sub

Open in new window

0
Jass Saini
Asked:
Jass Saini
1 Solution
 
PatHartmanCommented:
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?
0
 
Jass SainiAuthor Commented:
i could use the TransferSpreadSheet ...thank You
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now