PDA

View Full Version : [SOLVED:] Automation Error: Call was rejected by callee



Derek_123
03-18-2024, 07:00 AM
Hi guys,

I've written a macro in outlook that will extract the data from email body and copy it across excel spreadsheet. It's giving me below error:
run-time error '-214748111 (80010001)':
automation error
Call was rejected by callee.

Please see below the code:


Public Sub Extract()
On Error Resume Next
Set myOlApp = Outlook.Application
Set mynamespace = myOlApp.GetNamespace("mapi")
Dim strRowData As String
Dim strDelimiter As String
Dim myDestFolder As Folder
Dim olMailbox As Folder
Dim ShareInbox As Folder
Dim SubFolder As Folder
Dim InputFolder As String
Dim OutputFolder As String
Dim ProdMail As String
Dim oXLApp As Object, oXLwb As Object, oXLws As Object
Dim lRow As Long
On Error Resume Next
Set oXLApp = GetObject(, "Excel.Application")
'~~> If not found then create new instance
If Err.Number <> 0 Then
Set oXLApp = CreateObject("Excel.Application")
End If
Err.Clear
On Error GoTo 0
'~~> Open the relevant file
Set oXLwb = oXLApp.Workbooks.Open("X:\Test1.xlsx")
'Extract Mailbox and subfolder details from a sheet named as "Folder Details"
Set oXLws = oXLwb.Sheets("Folder Details")


Any help will be much appreciated.

Thanks

Derek_123
03-18-2024, 09:20 AM
Any idea how this issue can be resolved? Thanks

georgiboy
03-19-2024, 12:19 AM
Hi Derek_123,

On which line do you get the error?

Gasman
03-19-2024, 05:38 AM
Any idea how this issue can be resolved? Thanks

Wow, waited all of 20 mins? :(
Apologies for misreading the time on my phone. :banghead:

As mentioned, have you walked through your code with F8 and breakpoints?
I do not even see where you are touching the email body?

Aussiebear
03-19-2024, 06:24 AM
@Gasman, its a bit longer than 20 mins.

Gasman
03-19-2024, 08:44 AM
@Gasman, its a bit longer than 20 mins.

Oops, my apologies. :-(

The other questions still stand though?

This is the last line that I see in the code window

Set oXLws = oXLwb.Sheets("Folder Details")

Derek_123
03-20-2024, 02:23 AM
Hi guys, I'm getting the error at below line:


Set oXLwb = oXLApp.Workbooks.Open("X:\Test1.xlsx")


Any help will be much appreciated.

Gasman
03-20-2024, 04:51 AM
Have you checked you actually have an excel object?, as you have On Error Resume Next :(

Aussiebear
03-20-2024, 05:13 AM
is that a valid path to the document?

Derek_123
03-21-2024, 03:00 AM
Sorry It didn't recognize the path. After changing the folder path it worked. Thanks