From: Michael Guterl Date: 2006-09-22T02:29:41+09:00 Subject: Re: ruby/win32ole Excel Move problem ------=_Part_2112_7504335.1158859767530 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 9/21/06, Paul Lutus wrote: > > Craig Moran wrote: > > > I have been trying to implement this Excel subroutine in Ruby, > > So where's your Ruby code? That will help us help you. > > > but am having trouble with the Move command. > > I am having trouble finding out what trouble you are having. > > > The real issue is with the > > "after:=Sheets()" portion of the command in the code below. This may be of some help. Specifically the C# example code. It looks as the move method takes two parameters (before, after). Try passing nil for before if you want to use after as you cannot use both before and after combined... http://msdn2.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet.move.aspx What is the real issue, specifically? > > > Does anyone know how to get around this using Ruby and win32ole? > > Get around what, please? > > > This is what the code looks like in Excel VBA. All it does is sort the > > sheets of an Excel workbook by name. > > Thanks! > > You're most welcome. > > > Craig > > > > Sub Sheet_Sort() > > > > Dim shtCount As Integer > > shtCount = Sheets.Count > > > > For x = 3 To shtCount - 1 > > For i = 3 To shtCount - 1 > > If Worksheets(i).Name > Worksheets(i + 1).Name Then > > Worksheets(i).Move after:=Sheets(i + 1) > > End If > > Next i > > Next x > > > > End Sub > > Ruby code? By the way, the listed sort routine is an exceptionally > inefficient bubble sort. I strongly recommend that you read all the sheet > names into Ruby, sort them in Ruby, and write them out again. This would > most likely be faster than using the example above as a prototype, > especially as the number of data items increases. > > -- > Paul Lutus > http://www.arachnoid.com > > Michael Guterl ------=_Part_2112_7504335.1158859767530--