Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

-2147417851 (80010105) The server threw an exception.

Status
Not open for further replies.

mohebk

MIS
Aug 23, 2005
139
US
Hi,
I am writing a script in VBA to pull some values from an Excel spread sheet to update a Unix program using Attachemate Reflection. I am getting the error above on the file path line. I can't see anything wrong with it. Did anyone get this error before and was able to fix it?

Thanks.

Code:

Sub GetDataFromExcel()
'get data from an .xls worksheet...
'for reference documention on how to use Excel programmatically like
'this,
'open Excel, then open the Excel VBA Editor and select "Microsoft
'Visual Basic Reference"

Dim xl As New Excel.Application
Dim r As Integer
Dim c As Integer
Dim DataValue As String
Dim xlFile As Excel.Workbook

Set xlFile = xl.Workbooks.Open("C:\test.xls")

CR = Chr(Reflection2.ControlCodes.rcCR)
ESC = Chr(Reflection2.ControlCodes.rcESC)

With Session
For r = 1 To 3
For c = 1 To 3
DataValue = xlFile.Worksheets("Sheet1").Cells(r, c).Value
'send the data retrieved from Excel to the Reflection session
Session.Transmit DataValue & Chr(13)
Next
'Press VtF10 (Perform the Vt F10 function).
.TransmitTerminalKey rcVtF10Key
Next
End With
xl.Quit 'close excel when done

ErrorHandler:
Session.MsgBox Err.Description, vbExclamation + vbOKOnly

' Recording stopped at 14:19:54.69.
End Sub


Mo
 
Well you havn;t actually created the excel application so xl is an invalid reference

You need something more like:
Code:
Dim xl As New Excel.Application
    Dim r As Integer
    Dim c As Integer
    Dim DataValue As String
    Dim xlFile As Excel.Workbook
    
    [b]Set xl = New Excel.Application
    xl.visible = true[/b]
    Set xlFile = xl.Workbooks.Open("C:\test.xls")

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
D'OH - missed that

error message seems not to be related to opening the workbook - something more to do with the reflection session...

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Thank you both. It does not look like there is a lot of experts on reflection. I talked to their help desk and he was not that much of a help. He blamed it on Microsoft. I will try with him again. Still open for more suggestions though.

Mo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top