vba - Bringing an Excel window to foreground from Access -
i trying open excel file access , work, excel window pops in background (behind access window), not user friendly. here code use:
private function openexcelattachment() dim myxl object set myxl = createobject("excel.application") myxl dim fullpath string, name string name = "\excelfile.xlsx" fullpath = currentproject.path & name .workbooks.open fullpath .visible = true end
how can make excel window appear in foreground (on top of opened windows) instead?
thank you!
i first check open instance of excel. if must allow multiple instances of application, trickier. if ok using 1 instance of excel, think should work using appactivate statement.
private function openexcelattachment() dim myxl object on error resume next set myxl = getobject(,"excel.application") if err.number <> 0 set myxl = createobject("excel.application") on error goto 0 myxl dim fullpath string, name string name = "\excelfile.xlsx" fullpath = currentproject.path & name .workbooks.open fullpath .visible = true end appactivate "microsoft excel" end function
Comments
Post a Comment