Bulhac Mihai wrote:
> Yes, this is what i want, tnx a lot, but it gives me this error:
> 
>  OLE error code:800A03EC in Microsoft Office Excel
>       Programmatic access to Visual Basic Project is not trusted
> 
>     HRESULT error code:0x80020009
>       Exception occurred.  from excel2.rb:205:in `excel_asitt_menu'
>   from excel2.rb:349
> 
> my code is:
> 
> 
> modu = 
> $asitt_workbook.VBProject.VBComponents.Item($worksheet_asitt_menu)
> modu.CodeModule.InsertLines(1, "Private Sub " + $combo_box + "_Change")
> modu.CodeModule.InsertLines(2, " MsgBox " + $combo_box + ".Text" )
> modu.CodeModule.InsertLines(3, "End Sub")

previous error was resolved, but i still get one:

excel2.rb:207:in `method_missing': Item (WIN32OLERuntimeError)
    OLE error code:800A000D in VBAProject
      Type mismatch
    HRESULT error code:0x80020009
      Exception occurred.  from excel2.rb:207:in `excel_asitt_menu'

207 line is :
modu=$asitt_workbook.VBProject.VBComponents.Item($worksheet_asitt_menu)
-- 
Posted via http://www.ruby-forum.com/.