From: anon1m0us@... Date: 2006-12-13T05:50:10+09:00 Subject: Re: Directory Size and bolding Excel cells Ok, I got the cells to autofit using the below code. "#{loc} is a variable for my worksheets. excel.Worksheets("#{loc}").Columns("A:A").AutoFit excel.Worksheets("#{loc}").Columns("B:B").AutoFit excel.Worksheets("#{loc}").Columns("C:C").AutoFit excel.Worksheets("#{loc}").Columns("D:D").AutoFit excel.Worksheets("#{loc}").Columns("E:E").AutoFit anon1m0us@yahoo.com wrote: > Ok, I created a Macro in Excel to see what properties I need to you > with Excel. > When i use > excel.Worksheets(x).Columns("A:A").EntireColumn.AutoFit > excel.Worksheets(x).Columns("B:B").EntireColumn.AutoFit > > It does not autofit the cells. > > Timothy Brown wrote: > > Nope: > > > > excel.Worksheets(x).Cells(1, 1).Font.Bold = 1 > > excel.Worksheets(x).Cells(4, 1).Font.Bold = 1 > > > > A...Z 1....2 are references Excel uses, not Win32OLE. > > > > Tim > > > > On Dec 12, 2006, at 12:35 EST, anon1m0us@yahoo.com wrote: > > > > > I tried > > > excel.Worksheets(x).Cells("A1:D1").Font.Bold=1 > > > > > > > > > the (x) is a variable in a loop since I have numerous worksheets. > > > > > > > > > I receive the following error: > > > /test4.rb:17:in `method_missing': Cells (WIN32OLERuntimeError) > > > OLE error code:80020005 in > > > > > > HRESULT error code:0x80020009 > > > Exception occurred. from C:/test4.rb:17 > > > from C:/test4.rb:15 > > > > > > mully wrote: > > >> anon1m0us@yahoo.com wrote: > > >> > > >>> In addtion, how do you BOLD and hightlight and excel CELL?? > > >> > > >> Where ws is your Worksheet object and row and col are integers... > > >> > > >> ws.Cells(row, col).Font.Bold = 1 > > >> ws.Cells(row, col).Interior.ColorIndex = 6 > > >> > > >> One of the best ways to determine the necessary Excel objects and > > >> methods is to record a macro in Excel and then review the macro's VBA > > >> code. > > >> > > >> Mully > > > > > >