Article ID: 161149
Article Last Modified on 8/17/2005
Const MS_EXCEL_APP = "Excel.Application.5"and change it to this:
Const MS_EXCEL_APP = "Excel.Application"
api% = FindWindow(MS_EXCEL_CLASSNAME, lpNULL)
If api% = 0 Then ' FindWindow returns a non-zero ...
MsgBox MB_RUNEXCEL, vbExclamation + vbOK, MB_TITLE
End
End If
and remark it out by typing an apostrophe character (') at the
beginning of each line, like this:
'api% = FindWindow(MS_EXCEL_CLASSNAME, lpNULL)
'If api% = 0 Then ' FindWindow returns a non-zero ...
' MsgBox MB_RUNEXCEL, vbExclamation + vbOK, MB_TITLE
' End
'End If
NOTE: The complete comment on the second line is "FindWindow
returns a non-zero value if it finds the window."
Set oExcel = GetObject(,MS_EXCEL_APP)
and replace it with the following two lines of code:
Set oExcel = CreateObject(MS_EXCEL_APP)
oExcel.Visible = True
' Clean up and exit.
oExcel.Visible = True
oXLAssign.Select
oExcel.ScreenUpdating = True
AppActivate MS_EXCEL
oExcel.WindowState = MAXIMIZED
Set oExcel = Nothing
Exit Sub
and change the code to read as shown below:
' Clean up and exit.
oExcel.Visible = True
oXLAssign.Select
oExcel.ScreenUpdating = True
AppActivate oExcel.Caption
oExcel.WindowState = MAXIMIZED
Set oExcel = Nothing
Exit Sub
These changes allow the CareatePiviotTable macro to interact with Microsoft
Excel 97.
138723 XL7: Code to Access MS Excel Doesn't Work in Version 7.0
Additional query words: 4.00 pivot pivottables table create
Keywords: kbbug kbfix KB161149