call capturescreenshot("c:\test1.xls") public function capturescreenshot(filepath) '########################################################################### ########## 'function pastes the screen shots into excel or word file along with the date and time '############################################################################# ######## if right(filepath,4) = ".doc" then set wrd = createobject("word.application") 'wrd.visible = true wrd.documents.open filepath wrd.selection.typeparagraph wrd.selection.typeparagraph wrd.selection.typetext("date: "&date&chr(10)&"time: "&time) wrd.selection.typeparagraph wrd.selection.paste wrd.activedocument.save wrd.activedocument.close wrd.application.quit set wrd = nothing elseif right(filepath,4) = ".xls" then set objexcel = createobject("excel.application") objexcel.workbooks.open filepath set objworksheet = objexcel.activeworkbook.worksheets("sheet1") objworksheet.range("a1").select for i = 1 to 55 objexcel.selection.entirerow.insert next objworksheet.cells(1,1) = "date: "&date&chr(10)&"time: "&time objworksheet.range("d1").select objworksheet.paste objexcel.activeworkbook.save objexcel.activeworkbook.close objexcel.application.quit set objworksheet = nothing set objexcel = nothing end if end function