edthehorse
11-21-2012, 04:22 AM
hey i have been trying to get a window to come to the foreground on execution of a macro
the macro is set to calculate the sheet every two minutes using application.ontime, What i am looking to do have the sheet show up in front of the other windows on the screen with every calculation
Sub AutorecalcWorkbook()
'refresh the workbook per 2 mins
ThisWorkbook.Worksheets("Sheet1").Calculate
ThisWorkbook.Worksheets("Sheet2").Calculate
ThisWorkbook.Worksheets("Sheet3").Calculate
dNextTime = Now + TimeValue("00:02:00")
Application.OnTime dNextTime, "AutorecalcWorkbook"
End Sub
Sub showExcel()
Excel.Application.Visible = True
dNextTime = Now + TimeValue("00:02:00")
Application.OnTime dNextTime, "ShowExcel"
End Sub
i tried calling the show excel macro (without the ontime part) from the autocalc but nothing happened, when i run the macro manually from the vba window it brings the window to the foreground but when i call it from autocalc() it does nothing!
its probably something simpleas always! any help appreciated!
Cheers
ed
the macro is set to calculate the sheet every two minutes using application.ontime, What i am looking to do have the sheet show up in front of the other windows on the screen with every calculation
Sub AutorecalcWorkbook()
'refresh the workbook per 2 mins
ThisWorkbook.Worksheets("Sheet1").Calculate
ThisWorkbook.Worksheets("Sheet2").Calculate
ThisWorkbook.Worksheets("Sheet3").Calculate
dNextTime = Now + TimeValue("00:02:00")
Application.OnTime dNextTime, "AutorecalcWorkbook"
End Sub
Sub showExcel()
Excel.Application.Visible = True
dNextTime = Now + TimeValue("00:02:00")
Application.OnTime dNextTime, "ShowExcel"
End Sub
i tried calling the show excel macro (without the ontime part) from the autocalc but nothing happened, when i run the macro manually from the vba window it brings the window to the foreground but when i call it from autocalc() it does nothing!
its probably something simpleas always! any help appreciated!
Cheers
ed