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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime Error -2147417851 (80010105)

Status
Not open for further replies.

gazza110

Technical User
Apr 14, 2004
42
GB
Hi,

I have written some code from Excel to interact with attachmate and select all, copy and paste into excel. This appeared to be working yesterday, however everytime I try to run now I get this runtime error. My code is ...

--------------------------------------------------------
Code:
Sub Capture

Dim warn As Integer  ' No = 7    Yes = 6
warn = MsgBox("Are you sure you want to run this report?", vbCritical + vbYesNo + vbDefaultButton2, "Run Report")

If warn = 7 Then
Exit Sub
Else
End If

Sheets("Menu").Select
Dim dname As String
dname = Range("$C$2").Text

Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System")
If (System Is Nothing) Then
MsgBox "error1"
Stop
End If
Set Sessions = System.Sessions

If (Sessions Is Nothing) Then
MsgBox "error2"
Stop
End If


For Sess = 1 To Sessions.Count

If StrComp(Sessions.Item(Sess).Name, dname, vbTextCompare) = 0 Then Exit For
Next Sess

Dim Sess0 As Object
Set Sess0 = System.Sessions.Item(Sess)

If (Sess0 Is Nothing) Then
MsgBox "error3"
Stop
End If

If Not Sess0.Visible Then Sess0.Visible = True

Sheets("DataDump").Select
Range("E1:E9105").Select
Selection.ClearContents
Range("B1").Select

Again:

Dim Cont As String
Cont = Range("$K$1").Text

Dim NextDump As String
NextDump = Range("$K$2").Text

If Cont = "GO" Then
GoTo ScreenScrape
Else
Range("D1").Select
Exit Sub
End If

ScreenScrape:
Sess0.Screen.SelectAll
Sess0.Screen.Copy
Sess0.Screen.SendKeys ("<RollUp>")

Range(NextDump).Select
ActiveSheet.Paste

GoTo Again

End Sub
---------------------------------------------------------


Any ideas where I'm going wrong ???

Thanks,
Gary.
 
If you click the debug button VBA will show you the line of code that's throwing the error. From there it's a lot easier to identify the problem.

calculus
 
Hi calculus

The problem happens with the line

Code:
Sess0.Screen.SelectAll

When this is removed and you run the code it runs OK. After a few successful runs, you can then put the line back in and the program runs OK.

Very strange!
 
There are sometimes some undocumented features in EB.

Did you have anything else selected? I would think if it's intermittent that there's something different about the state of Extra when this line is executed.

calculus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top