#1
|
|||
|
|||
Runtime error "Remote Call Procedure Failed"
Hi everyone
I have been getting a a lot of help on this forum for my ongoing small project. Specifically, Paul aka macropad has helped me a lot. This issue actually has come pertaining to one of his code. I have been dealing with an issue lately. I have written a macro in MS word and exported it with relevant referenced Excel files to another system with different configuration.The details are as follows:- Current system: Windows 10 OS, MS Office 365 New system: Windows 7 OS, MS Office 2007 Upon running the code on the new system after importing it, the runtime error "remote procedure call failed "comes on the line Set xlWkBk = xlApp.Workbooks.Open(FileName:=StrWkBkNm, ReadOnly:=True, AddToMru:=False) I have already defined xlApp, xlwkBk as object and StrWkBkNm as location for Excel file. xlApp has also been set with Excel application object. The code runs perfectly on my current system. I have tried all sorts of variables for open method but it doesn't work. On giving the direct path of the database, it gives error sometimes as "Runtime error object required" or sometimes it gives error "open method of workbooks failed" . I have even changed the database file compatible to MS Excel 2007. But that doesn't work either. I am struggling with this since couple of days. Can't get through. Please help if you can.. Regards |
#2
|
||||
|
||||
You haven't provided anywhere near enough detail or code relevant to solving the problem. For example:
• Are you using early binding, or late binding? • If early binding, have you set a reference to Excel on the Office 2007 system? • Are the file paths exactly the same on both systems? • Does whatever workbook is named via StrWkBkNm exist in the same location on both systems? In the other thread where you initially asked this, I did say you needed to provide all the relevant code...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Remote Call procedure failed
Hi Paul. i ll share the entire code with requisite details below.
Code:
Application.ScreenUpdating = False Dim xlApp As Object, xlWkBk As Object, StrWkBkNm As String, StrWkSht As String Dim iDataRow As Long, i As Long Dim xlFList As String, xlRList As String StrWkBkNm = "C:\abvnsoftware\database\abvndatabase.xlsx" StrWkSht = "abvnlistwithspaceshyphenontop" 'code to create F/R list of two columns Set xlWkBk = .Workbooks.Open(FileName:=StrWkBkNm, ReadOnly:=True, AddToMru:=False) If xlWkBk Is Nothing Then MsgBox "Cannot open:" & vbCr & StrWkBkNm, vbExclamation .Quit: Set xlApp = Nothing: Exit Sub End If ' Process the workbook. With xlWkBk 'Ensure the worksheet exists If SheetExists(xlWkBk, StrWkSht) = True Then With .WorkSheets(StrWkSht) ' Find the last-used row in column A. iDataRow = .Cells(.Rows.Count, 1).End(-4162).Row ' -4162 = xlUp ' Capture the F/R data from the last three rows of the database. For i = (iDataRow - 2) To iDataRow If Trim(.Range("A" & i)) <> vbNullString Then xlFList = xlFList & "|" & Trim(.Range("A" & i)) xlRList = xlRList & "|" & Trim(.Range("B" & i)) End If Next End With Else MsgBox "Cannot find the designated worksheet: " & StrWkSht, vbExclamation Exit Sub End If .Close False End With End With ' Release Excel object memory Set xlWkBk = Nothing: Set xlApp = Nothing 'Exit if there are no data If xlFList = "" Then Exit Sub I have kept path same on both the systems and workbook exists on same location on both the system. Last edited by macropod; 03-04-2020 at 08:51 PM. Reason: Added code tags |
#4
|
||||
|
||||
The code you've posted is missing the code that tests for the workbook's existence and, moreover, the code to create an Excel session. See: https://www.msofficeforums.com/34254-post4.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Remote Call procedure failed
Hi Paul,
Apologies. I mistakenly posted erroneous code. The code with the errors as described earlier is below Code:
Application.ScreenUpdating = False Dim xlApp As Object, xlWkBk As Object, StrWkBkNm As String, StrWkSht As String Dim iDataRow As Long, i As Long ' Dim xlFList As String, xlRList As String StrWkBkNm = "C:\abvnsoftware\database\abvndatabase.xlsx" StrWkSht = "abvnlistwithspaceshyphenontop" If Dir(StrWkBkNm) = "" Then MsgBox "Cannot find the designated workbook: " & StrWkBkNm, vbExclamation Exit Sub End If On Error Resume Next 'Start Excel Set xlApp = CreateObject("Excel.Application") If xlApp Is Nothing Then MsgBox "Can't start Excel.", vbExclamation Exit Sub End If On Error GoTo 0 'code to process excel rows & columns With xlApp 'Hide our Excel session .Visible = False ' The file is available, so open it. Set xlWkBk = .Workbooks.Open(FileName:=StrWkBkNm, ReadOnly:=True, AddToMru:=False) If xlWkBk Is Nothing Then MsgBox "Cannot open:" & vbCr & StrWkBkNm, vbExclamation .Quit: Set xlApp = Nothing: Exit Sub End If ' Process the workbook. With xlWkBk 'Ensure the worksheet exists If SheetExists(xlWkBk, StrWkSht) = True Then With .WorkSheets(StrWkSht) ' Find the last-used row in column A. iDataRow = .Cells(.Rows.Count, 1).End(-4162).Row ' -4162 = xlUp ' Capture the F/R data from the last three rows of the database. For i = (iDataRow - 2) To iDataRow If Trim(.Range("A" & i)) <> vbNullString Then xlFList = xlFList & "|" & Trim(.Range("A" & i)) xlRList = xlRList & "|" & Trim(.Range("B" & i)) End If Next End With Else MsgBox "Cannot find the designated worksheet: " & StrWkSht, vbExclamation Exit Sub End If .Close False End With End With ' Release Excel object memory Set xlWkBk = Nothing: Set xlApp = Nothing 'Exit if there are no data If xlFList = "" Then Exit Sub The errors and problems described are as in previous posts of this thread. Also, when I exported the code with database to windows 10 is with Ms office 365 on another system, the code worked just fine. I don't know if the problem lies with Windows 7 OS or MS office 2007 or both. Regards. |
#6
|
||||
|
||||
You should close all instances of Excel, then check Task Manager to ensure you don't still have any orphaned Excel sessions running in the background. If you've messed up your code development, it's quite possible such an instance is keeping the workbook open.
Until you have the code running correctly, it's advisable to use: .Visible = True instead of: .Visible = False
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Quote:
Thanks |
#8
|
|||
|
|||
Remote Call Procedure failed error
Quote:
thanks Regards |
#9
|
||||
|
||||
The code you've posted is also missing the 'SheetExists' sub. Have you included that in your code module? Also, is any code line highlighted when the 'Remote Call Procedure Failed' error occurs?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#10
|
|||
|
|||
Quote:
Yes,sheetexist procedure is present in my code. And the error comes on the line, Set xlWkBk = .Workbooks.Open(FileName:=StrWkBkNm, ReadOnly:=True, AddToMru:=False) |
#11
|
||||
|
||||
Try changing that line to:
Set xlWkBk = .Workbooks.Open(StrWkBkNm, False, True)
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#12
|
|||
|
|||
I have tried that already..doesn't work..the only way the code works is when I keep the Excel session visible, i.e. .visible=true
|
#13
|
||||
|
||||
In that case, you may have a faulty Office installation. Try repairing it
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#14
|
|||
|
|||
Alright Paul.. I ll reinstall office then.
|
#15
|
||||
|
||||
Try repairing it first...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
"Floating" Text (Don't know what else to call it) | shawn.low@cox.net | Word | 0 | 05-31-2019 09:59 AM |
How to call up "Recovered Files" on demand | slavrenz | Office | 7 | 10-16-2015 05:57 PM |
Error: "Changes made were lost...reconnect with server", when switching "from" field | randhurrle | Outlook | 2 | 02-25-2015 06:51 PM |
Execution error 2147023170 - Failure call of distant procedure - POWERPOINT 2013 | fidecourt | PowerPoint | 2 | 02-26-2013 10:25 AM |
Microsoft Office 2010 programs display error message "Application has failed to start | SamSR | Office | 1 | 02-15-2011 07:15 AM |