Re: Excel Crashing when opened from Access



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




.



Relevant Pages

  • Re: My .xla custom menu items doesnt show up when using 3rd party software
    ... Excel & RunAutoMacros. ... Sub Auto_Close ... Dim cbcTools As CommandBarControl ... My routine only attempted to open only your own addin (none of any ...
    (microsoft.public.excel.programming)
  • Re: Code looping through files
    ... Dim myName As String ... Sub AllFolderFiles() ... Professional and I am using Excel 2003 Professional with Windows XP Media ... in a folder, opens each, does things, closes the file ...
    (microsoft.public.excel.programming)
  • RE: Cannot get code to work for API Save Dialog Box
    ... Dim strFilter As String ... 'Set filter to show only Excel spreadsheets ... With xlSheet ... Sub DetectExcel() ...
    (microsoft.public.access.forms)
  • EMail Outlook failing
    ... I moved the Excel files to the root drive in a sub folder and added ... "Excel cannot complete this task with available resources. ... Dim FileFormatNum As Long ... Dim TempFilePath As String ...
    (microsoft.public.excel.programming)
  • Re: SendKeys "(^ {HOME})"
    ... I've tried the following combos of VBA and Excel 2000 v9.0.2720 Application. ... right Cell being the only Cell in the lower, ... Public Sub SelectLoRtPaneUpLfCell() ... Dim lUpLfPaneMaxColNum As Long ...
    (microsoft.public.excel.programming)