On 9/12/07, Garry Bettle wrote:
> I've tried:
>
> oExcel.Range("A1").Select
> oExcel.Range("A1").NumberFormat = '0.00000'
>
> But the function result can still come back in scientific notation:
>
> i.e. -1.66542711967825E-32
>

Sorry for the reposting - 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:

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 the it print 0.75000 instead.

Cheers,

Garry


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to