Export to Excel with newer sheet in front

S

Song Su

I have following procedure to export roster to Excel and open it. The first
run is fine but later run, the sheet is at back. People always see the old
first sheet. How to display newer sheet in the front default?

Private Sub cmdGetIt_Click()
Dim sXL As String, oXL As Object
sXL = "Roster.xls"

Select Case fraSelect
Case Is = 1 And txtEmpNo <> "" 'My roster (EmpNo)
DoCmd.TransferSpreadsheet acExport, , "qryRosterMine", sXL
Case Is = 2 And cboSubject <> "" 'Course Roster
DoCmd.TransferSpreadsheet acExport, , "qryRosterSubj", sXL
Case Is = 3 And cboDept <> "" 'Department Roster
DoCmd.TransferSpreadsheet acExport, , "qryRosterDept", sXL
Case Is = 4 And cboSect <> "" 'Section Roster
DoCmd.TransferSpreadsheet acExport, , "qryRosterSect", sXL
End Select
If txtEmpNo <> "" Or cboSubject <> "" Or cboDept <> "" Or cboSect <> ""
Then
Set oXL = CreateObject("Excel.Application")
oXL.Visible = True
oXL.WorkBooks.Open FileName:=sXL
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top