Hi - have an Excel 2003 macro (below) that works fine - until I share the workbook at which point it fails with 'Run-time error '1004': Application-defined or object-defined error' the first time it's run, subsequent runs generate 'Run-time error '-214714848 (80010108)': Automation error The object invoked has disconnected from its clients.' The macro is attached to a command button on the workbook and inserts a new row in a spreadsheet and extends two data validation ranges (all done by a macro recording in the first place). Works fine until the workbook is shared, where it fails after the 'Test_extend_range Macro' comment - any ideas?
Code:
Private Sub AddNewLineDateButton_Click()
'
' AddNewLineDateButton Macro
'
'
Worksheets("Calls").Activate
Rows("13:13").Select
Selection.Insert Shift:=xlDown
Range("A13").Select
Rows("12:12").Select
Selection.Cut
Rows("13:13").Select
ActiveSheet.Paste
Dim DateTime As String
DateTime = Format(Date, "mm/dd/yy") & " " & Format(Time, "hh:mm")
Range("C12").Select
ActiveCell.Value = DateTime
Range("A12").Select
' Test_extend_range Macro
Range("A12:A13").Select
Range("A13").Activate
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$A$7:$A$11"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("F12:F13").Select
Range("F13").Activate
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$F$7:$F$8"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("A12").Select
End Sub