![]() |
Problem when Excel Not Maximized
Okay guys, this is a weird one.
I'm running the sample code below from Access to dump data to a worksheet, which works fine except for one thing. If Excel is already open when my code runs AND is minimized, the following happens: 1. Access gives focus to Excel and 2. Excel pops up (gets the focus), but does not maximize I do not want Excel to have focus until all of my code runs and I want it to show maximized. Interestingly, this does not happen if Excel is maximized already (like when Alt-Tabbing to different open applications). It also does not happen if Excel is NOT open when my code runs. The main reason this is an issue is because I am using the status bar in Access to let my users know the progress of the procedure and I don't want them to see the worksheet as it is being populated. I am using objXL.Visible = True at the end of my code, but this doesn't make any difference. The code below is just a small portion of code in my procedure, but seems to be where my issue is. Any help with this would be appreciated. SAMPLE CODE: 'Open workbook and Excel, if needed. If fIsAppRunning("Excel") Then Set objXL = GetObject(, "Excel.Application") boolXL = False Else Set objXL = CreateObject("Excel.Application") boolXL = True End If 'Set source file and path. FileName = DLookup("[TemplateFile]", "tblPaths", "[Process] = 'Daily Sum Report'") PathName = DLookup("[Path]", "tblPaths", "[Process] = 'Daily Sum Report'") 'Set Excel workbook. Set objActiveWkb = objXL.Workbooks.Open(PathName & FileName) Set objActiveWkb = objXL.Application.ActiveWorkbook Thanks, Clint |
Problem when Excel Not Maximized
You could use an API's first to get the window handle then set it to
foreground but try AppActivate Application.Caption Regards, Peter T "cherman" wrote in message ... Okay guys, this is a weird one. I'm running the sample code below from Access to dump data to a worksheet, which works fine except for one thing. If Excel is already open when my code runs AND is minimized, the following happens: 1. Access gives focus to Excel and 2. Excel pops up (gets the focus), but does not maximize I do not want Excel to have focus until all of my code runs and I want it to show maximized. Interestingly, this does not happen if Excel is maximized already (like when Alt-Tabbing to different open applications). It also does not happen if Excel is NOT open when my code runs. The main reason this is an issue is because I am using the status bar in Access to let my users know the progress of the procedure and I don't want them to see the worksheet as it is being populated. I am using objXL.Visible = True at the end of my code, but this doesn't make any difference. The code below is just a small portion of code in my procedure, but seems to be where my issue is. Any help with this would be appreciated. SAMPLE CODE: 'Open workbook and Excel, if needed. If fIsAppRunning("Excel") Then Set objXL = GetObject(, "Excel.Application") boolXL = False Else Set objXL = CreateObject("Excel.Application") boolXL = True End If 'Set source file and path. FileName = DLookup("[TemplateFile]", "tblPaths", "[Process] = 'Daily Sum Report'") PathName = DLookup("[Path]", "tblPaths", "[Process] = 'Daily Sum Report'") 'Set Excel workbook. Set objActiveWkb = objXL.Workbooks.Open(PathName & FileName) Set objActiveWkb = objXL.Application.ActiveWorkbook Thanks, Clint |
Problem when Excel Not Maximized
Thanks for the tip! I will try it out.
Clint "Peter T" wrote: You could use an API's first to get the window handle then set it to foreground but try AppActivate Application.Caption Regards, Peter T "cherman" wrote in message ... Okay guys, this is a weird one. I'm running the sample code below from Access to dump data to a worksheet, which works fine except for one thing. If Excel is already open when my code runs AND is minimized, the following happens: 1. Access gives focus to Excel and 2. Excel pops up (gets the focus), but does not maximize I do not want Excel to have focus until all of my code runs and I want it to show maximized. Interestingly, this does not happen if Excel is maximized already (like when Alt-Tabbing to different open applications). It also does not happen if Excel is NOT open when my code runs. The main reason this is an issue is because I am using the status bar in Access to let my users know the progress of the procedure and I don't want them to see the worksheet as it is being populated. I am using objXL.Visible = True at the end of my code, but this doesn't make any difference. The code below is just a small portion of code in my procedure, but seems to be where my issue is. Any help with this would be appreciated. SAMPLE CODE: 'Open workbook and Excel, if needed. If fIsAppRunning("Excel") Then Set objXL = GetObject(, "Excel.Application") boolXL = False Else Set objXL = CreateObject("Excel.Application") boolXL = True End If 'Set source file and path. FileName = DLookup("[TemplateFile]", "tblPaths", "[Process] = 'Daily Sum Report'") PathName = DLookup("[Path]", "tblPaths", "[Process] = 'Daily Sum Report'") 'Set Excel workbook. Set objActiveWkb = objXL.Workbooks.Open(PathName & FileName) Set objActiveWkb = objXL.Application.ActiveWorkbook Thanks, Clint |
All times are GMT +1. The time now is 01:55 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com