venugopal.p
New Member
- Joined
- Jun 11, 2010
- Messages
- 3
Hi,
Please help me in fixing the run time error problem
Exact error message is "Run-time error'-2147417848(80010108)':
Automation error
The object invoked has disconnected from its clients"
The above mentioned error comes occasionaly so it makes the macro unstable
What is wrong in the below code which makes that run time error?
Private Sub Worksheet_Change(ByVal Target As Range)
' This sub will help us in getting the workflow name based on the Folder
Dim OXL1 As Excel.Application
Set OXL1 = Excel.Application
OXL1.Application.EnableCancelKey = xlDisabled
OXL1.Application.ScreenUpdating = False
Dim folder, wfname, wfquery, destination As Variant
Dim KeyCells As Range
' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("B10")
If Not OXL1.Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
wfquery = "SELECT DISTINCT TASK_NAME,LAST_SAVED FROM OPB_TASK A WHERE TASK_TYPE=71 AND SUBJECT_ID IN (SELECT SUBJ_ID FROM OPB_SUBJECT WHERE SUBJ_NAME LIKE '%" & Sheet1.Range("b10").Value & "%' ) ORDER BY LAST_SAVED DESC"
Sheet3.Activate
Sheet3.Range("a1:a65536").Select
Selection.ClearContents
Sheet3.Range("a1").Select
Set destination = Sheet3.Range("a1:a65536")
With OXL1.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=D1EDW;UID=svinft0;PWD=temp;;DBQ=D1EDW;DBA=W;")), destination:=destination _
)
.CommandText = wfquery
.Name = "Query from D1EDW"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshStyle = xlInsertCells
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
Sheet1.Activate
Sheet1.Range("d10").Value = " Select a Workflow from Dropdown"
End If
OXL1.Application.ScreenUpdating = True
Set KeyCells = Range("d10")
If Not OXL1.Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
If Range("d10").Value = "" Then
MsgBox "Blank values are not allowed"
End If
End If
End Sub
Please help me in fixing the run time error problem
Exact error message is "Run-time error'-2147417848(80010108)':
Automation error
The object invoked has disconnected from its clients"
The above mentioned error comes occasionaly so it makes the macro unstable
What is wrong in the below code which makes that run time error?
Private Sub Worksheet_Change(ByVal Target As Range)
' This sub will help us in getting the workflow name based on the Folder
Dim OXL1 As Excel.Application
Set OXL1 = Excel.Application
OXL1.Application.EnableCancelKey = xlDisabled
OXL1.Application.ScreenUpdating = False
Dim folder, wfname, wfquery, destination As Variant
Dim KeyCells As Range
' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("B10")
If Not OXL1.Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
wfquery = "SELECT DISTINCT TASK_NAME,LAST_SAVED FROM OPB_TASK A WHERE TASK_TYPE=71 AND SUBJECT_ID IN (SELECT SUBJ_ID FROM OPB_SUBJECT WHERE SUBJ_NAME LIKE '%" & Sheet1.Range("b10").Value & "%' ) ORDER BY LAST_SAVED DESC"
Sheet3.Activate
Sheet3.Range("a1:a65536").Select
Selection.ClearContents
Sheet3.Range("a1").Select
Set destination = Sheet3.Range("a1:a65536")
With OXL1.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=D1EDW;UID=svinft0;PWD=temp;;DBQ=D1EDW;DBA=W;")), destination:=destination _
)
.CommandText = wfquery
.Name = "Query from D1EDW"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshStyle = xlInsertCells
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
Sheet1.Activate
Sheet1.Range("d10").Value = " Select a Workflow from Dropdown"
End If
OXL1.Application.ScreenUpdating = True
Set KeyCells = Range("d10")
If Not OXL1.Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
If Range("d10").Value = "" Then
MsgBox "Blank values are not allowed"
End If
End If
End Sub