#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default BUG????

I am using excel's object and found a bug in excel's
object. After getting the value for cell number 3425
(meaning for cell number 3426) data which originally was
123-4567 is returned as 1234567. I have done everything to
test that my code is not at fault but it appears not to be
so. I am using Office 2003 and my OS is Windows 2000 with
all the latest updates. Check out the code below:

Dim m_sExcelName as String
m_sExcelName = "c:\test.xls"

Dim oExcelAnother As New
Excel.Application
Dim oInternalWorkBook As Excel.Workbook,
oInternalWorksheet As Excel.Worksheet
Set oInternalWorkBook = oExcelAnother.Workbooks.Open
(m_sExcelName)
Set oInternalWorksheet = oInternalWorkBook.Sheets(1)
Dim iRowCount as Integer
iRowCount = 5000
Dim iColCount as Integer
iColCount= 20
Dim iLoop as Integer
iLoop=0
For iRowLoop = 2 To iRowCount
For iLoop = 1 To iColCount
Dim sVal As String
sVal = CStr(excelTemp.Cells(iRowLoop, iLoop))
Next iLoop
Next iRowLoop

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default BUG????

Hi
have you checked that there's no custom format applied to this cell?

--
Regards
Frank Kabel
Frankfurt, Germany

"CodeSplit" schrieb im
Newsbeitrag ...
I am using excel's object and found a bug in excel's
object. After getting the value for cell number 3425
(meaning for cell number 3426) data which originally was
123-4567 is returned as 1234567. I have done everything to
test that my code is not at fault but it appears not to be
so. I am using Office 2003 and my OS is Windows 2000 with
all the latest updates. Check out the code below:

Dim m_sExcelName as String
m_sExcelName = "c:\test.xls"

Dim oExcelAnother As New
Excel.Application
Dim oInternalWorkBook As Excel.Workbook,
oInternalWorksheet As Excel.Worksheet
Set oInternalWorkBook = oExcelAnother.Workbooks.Open
(m_sExcelName)
Set oInternalWorksheet = oInternalWorkBook.Sheets(1)
Dim iRowCount as Integer
iRowCount = 5000
Dim iColCount as Integer
iColCount= 20
Dim iLoop as Integer
iLoop=0
For iRowLoop = 2 To iRowCount
For iLoop = 1 To iColCount
Dim sVal As String
sVal = CStr(excelTemp.Cells(iRowLoop, iLoop))
Next iLoop
Next iRowLoop


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default BUG????

What's the original datatype of that cell?

if it's a value formatted as 123-456 you'll see this behaviour.

also your code will fail if the cells containt error values.

Since you're converting it to text anyway....why not use the .Text
property (that'll give you the cell's DISPLAYED value including the
cells' numberformat rounding etc.)

Please have a carefull look at .Value / .Value2 and .Text property

btw Personally i wouldn't put a dim inside a loop!

dim sTmp$
for i=1 to x
sTmp=wks.cells(i,j).Text
next


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"CodeSplit" wrote:

I am using excel's object and found a bug in excel's
object. After getting the value for cell number 3425
(meaning for cell number 3426) data which originally was
123-4567 is returned as 1234567. I have done everything to
test that my code is not at fault but it appears not to be
so. I am using Office 2003 and my OS is Windows 2000 with
all the latest updates. Check out the code below:

Dim m_sExcelName as String
m_sExcelName = "c:\test.xls"

Dim oExcelAnother As New
Excel.Application
Dim oInternalWorkBook As Excel.Workbook,
oInternalWorksheet As Excel.Worksheet
Set oInternalWorkBook = oExcelAnother.Workbooks.Open
(m_sExcelName)
Set oInternalWorksheet = oInternalWorkBook.Sheets(1)
Dim iRowCount as Integer
iRowCount = 5000
Dim iColCount as Integer
iColCount= 20
Dim iLoop as Integer
iLoop=0
For iRowLoop = 2 To iRowCount
For iLoop = 1 To iColCount
Dim sVal As String
sVal = CStr(excelTemp.Cells(iRowLoop, iLoop))
Next iLoop
Next iRowLoop



  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default BUG????

thanks dude
yea that was it.... :)
any ideas how i can convert the custom format to actual
format so that i only get 123-4567 as value and not 1234567
when i retrieve it from the cell.


-----Original Message-----
Hi
have you checked that there's no custom format applied to

this cell?

--
Regards
Frank Kabel
Frankfurt, Germany

"CodeSplit" schrieb

im
Newsbeitrag news:145c501c444b9$da63d230

...
I am using excel's object and found a bug in excel's
object. After getting the value for cell number 3425
(meaning for cell number 3426) data which originally was
123-4567 is returned as 1234567. I have done everything

to
test that my code is not at fault but it appears not to

be
so. I am using Office 2003 and my OS is Windows 2000

with
all the latest updates. Check out the code below:

Dim m_sExcelName as String
m_sExcelName = "c:\test.xls"

Dim oExcelAnother As New
Excel.Application
Dim oInternalWorkBook As Excel.Workbook,
oInternalWorksheet As Excel.Worksheet
Set oInternalWorkBook = oExcelAnother.Workbooks.Open
(m_sExcelName)
Set oInternalWorksheet = oInternalWorkBook.Sheets(1)
Dim iRowCount as Integer
iRowCount = 5000
Dim iColCount as Integer
iColCount= 20
Dim iLoop as Integer
iLoop=0
For iRowLoop = 2 To iRowCount
For iLoop = 1 To iColCount
Dim sVal As String
sVal = CStr(excelTemp.Cells(iRowLoop, iLoop))
Next iLoop
Next iRowLoop


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default BUG????

Hi
you have to enter this kind of value manually or use in a helper column
a formula like
=TEXT(A1,"000-0000")

--
Regards
Frank Kabel
Frankfurt, Germany

schrieb im Newsbeitrag
...
thanks dude
yea that was it.... :)
any ideas how i can convert the custom format to actual
format so that i only get 123-4567 as value and not 1234567
when i retrieve it from the cell.


-----Original Message-----
Hi
have you checked that there's no custom format applied to

this cell?

--
Regards
Frank Kabel
Frankfurt, Germany

"CodeSplit" schrieb

im
Newsbeitrag news:145c501c444b9$da63d230

...
I am using excel's object and found a bug in excel's
object. After getting the value for cell number 3425
(meaning for cell number 3426) data which originally was
123-4567 is returned as 1234567. I have done everything

to
test that my code is not at fault but it appears not to

be
so. I am using Office 2003 and my OS is Windows 2000

with
all the latest updates. Check out the code below:

Dim m_sExcelName as String
m_sExcelName = "c:\test.xls"

Dim oExcelAnother As New
Excel.Application
Dim oInternalWorkBook As Excel.Workbook,
oInternalWorksheet As Excel.Worksheet
Set oInternalWorkBook = oExcelAnother.Workbooks.Open
(m_sExcelName)
Set oInternalWorksheet = oInternalWorkBook.Sheets(1)
Dim iRowCount as Integer
iRowCount = 5000
Dim iColCount as Integer
iColCount= 20
Dim iLoop as Integer
iLoop=0
For iRowLoop = 2 To iRowCount
For iLoop = 1 To iColCount
Dim sVal As String
sVal = CStr(excelTemp.Cells(iRowLoop, iLoop))
Next iLoop
Next iRowLoop


.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default BUG????

Use the Text property of the cell object to get the formatted result.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
thanks dude
yea that was it.... :)
any ideas how i can convert the custom format to actual
format so that i only get 123-4567 as value and not 1234567
when i retrieve it from the cell.


-----Original Message-----
Hi
have you checked that there's no custom format applied to

this cell?

--
Regards
Frank Kabel
Frankfurt, Germany

"CodeSplit" schrieb

im
Newsbeitrag news:145c501c444b9$da63d230

...
I am using excel's object and found a bug in excel's
object. After getting the value for cell number 3425
(meaning for cell number 3426) data which originally was
123-4567 is returned as 1234567. I have done everything

to
test that my code is not at fault but it appears not to

be
so. I am using Office 2003 and my OS is Windows 2000

with
all the latest updates. Check out the code below:

Dim m_sExcelName as String
m_sExcelName = "c:\test.xls"

Dim oExcelAnother As New
Excel.Application
Dim oInternalWorkBook As Excel.Workbook,
oInternalWorksheet As Excel.Worksheet
Set oInternalWorkBook = oExcelAnother.Workbooks.Open
(m_sExcelName)
Set oInternalWorksheet = oInternalWorkBook.Sheets(1)
Dim iRowCount as Integer
iRowCount = 5000
Dim iColCount as Integer
iColCount= 20
Dim iLoop as Integer
iLoop=0
For iRowLoop = 2 To iRowCount
For iLoop = 1 To iColCount
Dim sVal As String
sVal = CStr(excelTemp.Cells(iRowLoop, iLoop))
Next iLoop
Next iRowLoop


.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"