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: 16
Default VBA Excel - Run-time Error 50289 €“ Can't perform operation

Hi guys,
I am trying to use the following block of code to insert a function in a
worksheet.
If the VBA Project is not protected, the macro runs just fine, but when
locking the project for viewing, I get the following error:
"Run-time Error 50289 €“ Can't perform operation since the project is
protected"
How can I work it around?
Thanks in advance,
Aldo.

Function CreateProcedureForIndex(Optional wksName As String, Optional
eventName As String, Optional objectName As String)
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim LineNum As Long

Const DQUOTE = """" 'one " character
Set VBProj = ActiveWorkbook.VBProject
Set VBComp = VBProj.VBComponents(Sheets(wksName).CodeName)
Set CodeMod = VBComp.CodeModule

With CodeMod
LineNum = LineNum + 1: .InsertLines LineNum, "Option Explicit"
LineNum = .CreateEventProc(eventName, objectName) ' + 1
LineNum = LineNum + 1: .InsertLines LineNum, " If
Cells(Target.row, Target.Column + 1).Value = ""Chart Sheet"" Then"
LineNum = LineNum + 1: .InsertLines LineNum, "
Charts(Target.Value).Activate"
LineNum = LineNum + 1: .InsertLines LineNum, " End if"
End With
End Function

 
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
Is there a function to perform this operation? Ayo Excel Discussion (Misc queries) 2 July 17th 09 03:17 AM
Cant perform operation since the project is protected PaulSimonGB Excel Programming 0 January 25th 09 11:57 PM
Can't perform requested operation in excel macro John[_19_] Excel Programming 2 March 12th 08 03:54 AM
Connection Cannot Be Used to Perform this Operation alexcn Excel Programming 0 May 8th 07 07:13 PM
Proplem copying a Module - Error 50289 Trefor Excel Programming 2 January 21st 06 12:10 AM


All times are GMT +1. The time now is 06:51 AM.

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

About Us

"It's about Microsoft Excel"