Re: weird, hard to find Excel-automation error



Thanks for all your help everybody.
I got it working although I'm not excactly sure how.

I think the error was related to using:
..Range(Cells(i, 1), Cells(i, 5)).
instead of
..Range(.Cells(i, 1), .Cells(i, 5)).

inside a:
With objExcelDoc.Sheets(1)
....
End with
and thus me not referencing the active *** (?). since the error only
occured on subsequent print out and not on the first one. I'm not completely
sure.
Thanks for all your comments.


Jesper


"Ken Snell (MVP)" <kthsneisllis9@xxxxxxxxxxxxxxxxxx> skrev i en meddelelse
news:eSWwo1e%23FHA.3676@xxxxxxxxxxxxxxxxxxxxxxx
> You'll need to post all your code so that we can see what is being done.
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
> "Jesper Fjølner" <askfor@xxxxxxxxxxx> wrote in message
> news:uDoAkke%23FHA.912@xxxxxxxxxxxxxxxxxxxxxxx
>> I'm sending some data to Excel, but I'm getting a couple of strange
>> errors intermittently.
>> Approximately every other time everything runs without problems and fails
>> every other time.
>> I have Access open up Excel with the code below. When I close the Excel
>> window it seems that "Excel.exe" remains in my task list (ctrl-alt-del).
>> So I suspect it has something to do with wrongful opening or closing of
>> the app, but can't locate it.
>>
>> I'm using:
>>
>> Dim objExcelApp As Object 'late binding
>> Dim objExcelDoc As Object 'late binding
>> Set objExcelApp = CreateObject("excel.application") 'late binding
>> Set objExcelDoc = objExcelApp.Workbooks.Add
>>
>> Code usually fails at the first insert into a cell such as:
>> objExcelDoc.Sheets(1).range("A1").Value = "text"
>>
>> I end the procedure with:
>> Set objExcelDoc = Nothing
>> Set objExcelApp = Nothing
>>
>> The errors I get are:
>> Run-time error '462'
>> The remote server machine does not exist or is unvailable
>> or
>> Rune-time error '1004'
>> Method 'Range' of object '_Global' failed
>>
>> The error newer occours on the first run, but always on the second and
>> subsequent.
>> If I close and reopen the database, it runs again on the first run and
>> fails on the subsequent.
>> Even though I terminate Excel.exe via the tasklist, the error doesn't go
>> away before I restart the database.
>> Can anyone point me in a direction?
>>
>>
>> Jesper F
>>
>>
>>
>
>


.