C
cherman
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
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