Setting Excel Column width through OLE (OpenInsight 32-Bit)
At 27 FEB 2007 11:48:55AM Hans Stek wrote:
Hi,
For the OLE / Excel Buffs amongst you..
Below is a snippet of my code to do with reading a Date from an Excel Spreadsheet.
The problem is that if the column of the read cell is too small for the date to display ######## is returned, same as you would see on screen.
So question is how can I set / change the column width if this happens? (Manual change is no option). I know there is a VBScript statement ActiveCell.ColumnWidth but I have had no luck translating it to OI. (Maybe to do with not setting the active cell correct?)
=============================================
oXl=OleCreateInstance('excel.Application')
oWkbks=oXl-]WorkBooks
oSheet=OleGetProperty(oWkbks, 'Open', filename, 0, 1, 1, Password)
oXl-]Visible=0
oCells=OleGetProperty(oSheet, 'Worksheets',1)
Cell=OleGetProperty(oCells,'Cells',9,12)
cRec=Iconv(Cell-]Text, 'D')
close=OleCallMethod(oSheet, 'Close',0)
close=OleCallMethod(oXL, 'Quit')
=============================================
Thank you,
Hans.
At 27 FEB 2007 11:58AM Hans Stek wrote:
Don't you hate that when it happens. You spend a few hours trying to solve the problem and you find it 5 minutes after you post the question… Sorry.
Answer is use the Value variable and not the Text one:
cRec=Iconv(Cell-]Value, 'D')
Hans.