From: Bulhac Mihai Date: 2007-09-30T18:16:00+09:00 Subject: Re: OLE Object - combo box problem Masaki Suketa wrote: > Hello, > Bulhac Mihai wrote: > > 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) > > Is $worksheet_asitt_menu WIN32OLE object? > If so, try > Item($worksheet_asitt_menu.name) > > Item's argument must be Worksheet name string(ie. String object) > not WIN32OLE object. > > Regards, > Masaki Suketa i have this: $excel = WIN32OLE.new('Excel.Application') $worksheet_asitt_menu = $asitt_workbook.Worksheets(1) $worksheet_asitt_menu.name="ASITT_MENU" $combo_box=$worksheet_asitt_menu.OLEObjects.Add("Forms.Combobox.1").object modu = $asitt_workbook.VBProject.VBComponents.Item($worksheet_asitt_menu.name) modu.CodeModule.InsertLines(1, "Private Sub ComboBox1_Change") modu.CodeModule.InsertLines(2, " MsgBox \"asdasd\"" ) modu.CodeModule.InsertLines(3, "End Sub") -combobox1 is the name for combo box with this code i still have that error: excel2.rb:208:in `method_missing': Item (WIN32OLERuntimeError) OLE error code:800A0009 in VBAProject Subscript out of range HRESULT error code:0x80020009 Exception occurred. from excel2.rb:208:in `excel_asitt_menu' from excel2.rb:352 #line 208: modu = $asitt_workbook.VBProject.VBComponents.Item($worksheet_asitt_menu.name) -- Posted via http://www.ruby-forum.com/.