Export data to a excel sheet on selection of a view

hi all, i have a view and a action button on the view in my application.clicking on yhe button a excel sheet generates.i want to generate the excel sheet on selection in view.How can i do this??

Subject: export data to a excel sheet on selection of a view

Set collection = db.UnprocessedDocumentsIf collection.Count = 0 Then

Messagebox "Not found", , "Search for "

end If

Subject: RE: export data to a excel sheet on selection of a view

on view it is done.but if i want to do it on embeddedview,what i have to do?i am trying the same code on embedded view.but its not working.