I'm really going crazy after failing all day to debug this.
Has anyone successfully used the .NumberFormat of Excel's Range function during automation?
I don't know why but I can't ... code to follow:
The last line prints 0.7500000000 - I would have expected that .NumberFormat = '0.00000' would make it print 0.75000 instead.
Cheers,
Garry
Has anyone successfully used the .NumberFormat of Excel's Range function during automation?
I don't know why but I can't ... code to follow:
Code:
oExcel = CREATEOBJECT( [Excel.Application])
IF VARTYPE( oExcel) != [O]
* could not instantiate Excel object
RETURN .F.
ENDIF
oExcel.SheetsInNewWorkbook = 1
oExcel.Workbooks.CLOSE
oExcel.Workbooks.ADD
oExcel.VISIBLE = .F.
* lcLinest = [12.5,13,12.5,12,13,12.5,13,12.5,12,12.5,13]
lcLinest = [12.5,13,14]
lnLinest = 0
IF !EMPTY( lcLinest)
lnWordCount = GETWORDCOUNT( lcLinest, [,])
IF lnWordCount >= 3
lcClipText = [=linest({] + lcLinest + [})]
oExcel.Range("A1").Select
oExcel.Range("A1").value = lcCliptext
oExcel.Range("A1").NumberFormat = '0.00000'
lnLinest = oExcel.Range("A1").value
ENDIF
ENDIF
oExcel.DisplayAlerts = .F.
oExcel.workbooks.CLOSE
oExcel.QUIT
RELEASE oExcel
? lnLinest
The last line prints 0.7500000000 - I would have expected that .NumberFormat = '0.00000' would make it print 0.75000 instead.
Cheers,
Garry