LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding validation fails with automation error

I'm using Visual Basic 6.5 and Excel 2003 SP3. Here's some excerpts
from a sub:

Dim rMyRange As Range

With wksMyWorksheet ' name of a worksheet
Set rMyRange = Range(.Cells(4, 2), .Cells(10, 2))
End With

With rMyRange.Validation
.Delete
.Add Type:=Excel.xlValidateDecimal,
AlertStyle:=Excel.xlValidAlertStop, Operator:=Excel.xlGreaterEqual,
Formula1:="0"
.IgnoreBlank = False
.InCellDropdown = False
.ErrorTitle = "Error"
.ErrorMessage = "Must be = 0"
.ShowError = True
End With

When I run this, I sometimes get, when adding the validation: Run-time
error '-2147417848 (80010108' : Method 'Add' of object 'Validation'
failed. Sometimes it says "Automation error. The object invoked has
disconnected from its clients".

The workaround I have is to do:
rMyRange.Select
With Selection.Validation
...
End With

instead, which cures the problem, but I don't see why this should be
necessary or why the original code fails. The Microsoft page
http://support.microsoft.com/default...;en-us;Q319832 is not
enlightening.

Any ideas?

Thanks in advance,
Philip.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automation error with XLA addin, fails on commandbarbutton onaction [email protected] Excel Programming 0 August 13th 07 07:14 AM
Adding Validation When Source Validates To Error? (PeteCresswell) Excel Programming 4 July 7th 07 10:55 PM
Validation fails on copying x6v87qe Excel Discussion (Misc queries) 3 May 8th 07 09:10 AM
VBA Inserted Data Validation Fails _RickK Excel Programming 3 January 24th 07 05:18 PM
Excel fails to open workbook using Automation from VB 6 Lowell Excel Programming 0 September 8th 05 05:33 AM


All times are GMT +1. The time now is 07:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"