ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   exception at 0x6503999b (VBE6.DLL) - Please (https://www.excelbanter.com/excel-programming/272210-exception-0x6503999b-vbe6-dll-please.html)

Fred[_10_]

exception at 0x6503999b (VBE6.DLL) - Please
 
I constantly get the following error when I get to
the ".InsertLines" of the code listed below the error.

Can anyone help
First-chance exception at 0x6503999b (VBE6.DLL) in
EXCEL.EXE: 0xC0000005: Access violation writing location
0x5c00800f.
Unhandled exception at 0x6503999b (VBE6.DLL) in EXCEL.EXE:
0xC0000005: Access violation writing location 0x5c00800f.

Sub Insert_Code()
Dim obvbc As VBIDE.VBComponent, lLine As Long
With Workbooks("Booked Sales by AS Rep Actuals.xls")
Set obvbc = .VBProject.VBComponents(.ActiveChart.CodeName)
End With
With obvbc.CodeModule
lLine = .CreateEventProc("Calculate", "chart")
.InsertLines lLine, "'Reset Custom Color Option"
.ReplaceLine lLine + 2, "ActiveChart.SeriesCollection
(1).Select" & vbCrLf & _
"If Selection.Interior.ColorIndex < 23 Then" &
vbCrLf & _
" With Selection.Border" & vbCrLf & _
" .ColorIndex = 5" & vbCrLf & _
" .Weight = xlThin" & vbCrLf & _
" .LineStyle = xlContinuous" & vbCrLf & _
" End With" & vbCrLf & _
"Selection.Shadow = False" & vbCrLf & _
"Selection.InvertIfNegative = False" & vbCrLf & _
" With Selection.Interior" & vbCrLf & _
" .ColorIndex = 23" & vbCrLf & _
" .Pattern = xlSolid" & vbCrLf & _
" End With" & vbCrLf & _
"End If"
End With
Set obvbc = Nothing
End Sub


All times are GMT +1. The time now is 12:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com