Hey Keith,
Me again, lol..
I've added you code to mine and when i run the program, which first checks if the block exists, which works, then i edit the userform as i'm meant to, then hit go and it errors out on the For Each OldBlkRef In ThisDrawing.PaperSpace line, with a Type Mismatch error even though there are blatantly other blocks (of the same name) in paperspace - would could be wrong?
'If Insert Chart (and update existing ones) is chosen..
ElseIf want1OPT.Caption = " Insert Chart (and update existing ones).." Then
[color=red]For Each OldBlkRef In ThisDrawing.PaperSpace[/color]
With OldBlkRef
If .Name = "Fixings_Chart" Then
Set NewBlkRef = ThisDrawing.PaperSpace.InsertBlock(.InsertionPoint, .Name, .XScaleFactor, .YScaleFactor, .ZScaleFactor, .Rotation)
NewBlkRef.Layer = .Layer
NewBlkRef.color = .color
NewBlkRef.Linetype = .Linetype
NewBlkRef.LinetypeScale = .LinetypeScale
NewBlkRef.Lineweight = .Lineweight
NewBlkRef.Normal = .Normal
NewBlkRef.Visible = .Visible
.Delete
End If
End With
Next OldBlkRef
' Check if table exists and redefine (clearout) the block of all data before creating and inserting the new instance..
Dim Blk1 As AcadBlock
If acBlock.BlockExists("Fixings_Chart").Exists = True Then
Set Blk1 = ThisDrawing.Blocks.Item("Fixings_Chart")
CleanoutBlock Blk1 '<-- call the CleanoutBlock function here
End If
CREATEChart
INSERTChart