Re: Excel Crashing when opened from Access
- From: "Phil Stanton" <phil@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 29 Jun 2007 22:43:20 +0100
Thanks Roy. Will try that
Phil
"RoyVidar" <roy_vidarNOSPAM@xxxxxxxx> wrote in message
news:mn.eaa37d768781a5de.59509@xxxxxxxxxxx
"Phil Stanton" <phil@xxxxxxxxxxxxxxxxxxx> wrote in message
<4683f41f$0$8749$ed2619ec@xxxxxxxxxxxxxxxxxxxxxxxxxx>:
I am using the following code (Office 2000)
Private Sub Storage_Click()
On Error GoTo Err_Storage_Click
Dim ExcelApp As Object
Dim ExcelWasNotRunning As Boolean ' Flag for final
release Dim MyDb As Database
On Error Resume Next
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = True
If Err.Number <> 0 Then ExcelWasNotRunning = True
Err.Clear ' Clear Err object in case error occurred.
' Check for Microsoft Excel. If Microsoft Excel is running,
' enter it into the Running Object table.
DetectExcel
' Set the object variable to reference the file you want to see.
Set ExcelApp = GetObject("C:\Documents and Settings\Phil\My
Documents\Access\MDB\WFYC\Storage.XLS")
' Show Microsoft Excel through its Application property. Then
' show the actual window containing the file using the Windows
' collection of the ExcelApp object reference.
ExcelApp.Application.Visible = True
ExcelApp.Parent.Windows(1).Visible = True
Exit_Storage_Click:
Exit Sub
Err_Storage_Click:
MsgBox Err.Description
Resume Exit_Storage_Click
End Sub
Sub DetectExcel()
' Procedure dectects a running Excel and registers it.
Const WM_USER = 1024
Dim hWnd As Long
' If Excel is running this API call returns its handle.
hWnd = FindWindow("XLMAIN", 0)
If hWnd = 0 Then ' 0 means Excel not running.
Exit Sub
Else
' Excel is running so use the SendMessage API
' function to enter it in the Running Object Table.
SendMessage hWnd, WM_USER + 18, 0, 0
End If
End Sub
This opens up the Excel application OK (It is using data in the
database) If I click on pretty much anything in the Excel
application it immediately crashes. If I click on something in
Access immediately after Eccel opens, then return to Eccel - I get a
message that th ODBC Microsoft Access Driver Login Failed and the
data fails to update. If I open Excel with the Access DB closed,
everything works perfectly.
Would appreciate advice
Thanks
Phil
If this is all the code, and if I understand correct, I'd try
shelling in stead of automating.
For instance using ShellExecute (check out the handy wrapper from
http://www.mvps.org/access/api/api0018.htm)
--
Roy-Vidar
.
- References:
- Excel Crashing when opened from Access
- From: Phil Stanton
- Re: Excel Crashing when opened from Access
- From: RoyVidar
- Excel Crashing when opened from Access
- Prev by Date: Re: Frustrated re Line method
- Next by Date: Re: Excel Crashing when opened from Access
- Previous by thread: Re: Excel Crashing when opened from Access
- Next by thread: find mdb parent of mde
- Index(es):
Relevant Pages
|