Hi Vidal
Yes you can do this in Access. You don't need the command button in Excel for this to work.
Put the following code behine the 'On Click' property of a command button on a form in Access.
This will output the results of a query (called "Query1") in Excel format, to the C:\Temp folder.
For this example, the code will only select Cell "B2" and then save the workbook. You will have to delete these 2 lines of code and add you own.
You must ensure that the 'Microsoft Excel Object Library' is referenced for this code to work.
(This can be found under Tools - References from inside the VBA editor)
Private Sub cmd1_Click()
On Error GoTo Err_Handler
DoCmd.OutputTo acOutputQuery, "Query1", "Microsoft Excel (.xls)", "C:\Temp\Test.xls", False
Dim xlApp As Excel.Application, xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
xlApp.Application.Visible = False
xlApp.Workbooks.Open "C:\Temp\Test.xls"
Set xlSheet = xlApp.ActiveSheet
' Below, you need to add the code to do whatever is required in the Excel sheet
Range("B2").Select
ActiveWorkbook.Save
' Delete the above 2 lines when you have added your code
xlApp.Application.Visible = True
'Clean up here
Set xlSheet = Nothing
Set xlApp = Nothing
End
Exit_cmd1_Click:
End
Exit Sub
Err_Handler:
MsgBox "Error: " & Err.Number & " - " & Err.Description
Resume Exit_cmd1_Click
End Sub
Hope this is what you wanted.