RPC Exception in Excel.Application

Deepthiv

Active member
Joined
Oct 3, 2005
Messages
39
Programming Experience
3-5
I am using a function to add excelsheet to excelbook (passing excelbook object as reference). (For dynalic insertion of excel sheets in book , i am updating iNumber)

Public Function AddExcelSheet( ByRef Xlb As Object, Optional ByVal sWorkBookName As String = "") As Object
Dim Xlsw As Excel.Worksheet
Xlsw = CType(Xlb.worksheets(iNumber), Excel.Worksheet)
iNumber = iNumber + 1
Xlsw.Name = sWorkBookName
Return Xlsw
End Function

but when i calling this function, I am getting exception "The RPC Server is unavaliable" for line

Xlsw = CType(Xlb.worksheets(iNumber), Excel.Worksheet)

Can anyone please throw light on this

regards,
Deepthi

 
Just a guess but could it have anything to do with the fact that you are late-binding the Xlb argument. It's passed as Object and you're obviously assuming that it has a worksheets property, so why not declare it as the appropriate type. That's good advice even if that's not the cause.
 
Can you please be more clear on this front.

I want to create 'n' sheets with in one workbook, depending upon bussiness logic and user input 'n' will be decided..

is there any way to get this 'RPC' problem down... Please suggest me in this regard
 
I am doing Late Binding coz i want my application to run both on office 2000 and office 2003..

Is there any other way??
 
Can someone please throw some light on this issue..

I am getting this exception on both office 2000 and office 2003.



Regards,
Deepthi
 
Back
Top