export data to excel

Posted on 2003-03-18
Medium Priority
Last Modified: 2010-05-01

I exported data from a flexgrid to an excel-sheet. Now I have another problem. The data in the flexgrid are not recognized as doubles in excel. All the data with a comma, are recognized as strings. How can I change this? So how can I make excel recognize my data with comma's as normal data.

this is the code:

Set ApExcel = CreateObject("Excel.application") 'Creates an object
ApExcel.Visible = True ' So you can see Excel
ApExcel.Workbooks.Add 'Adds a new book.
For x = 1 To aantal
For y = 1 To aantal
ApExcel.selection.numberformat = ""
ApExcel.Cells(x, y).Value = MSFlexGrid1.TextMatrix(x, y) 'Add Text to a Cell
'You can use the line above, changing coordenates to go to any
'cell and you can also add Formulas

Question by:yoske1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 11

Expert Comment

ID: 8163485
how about...

ApExcel.Cells(x, y).Value = MSFlexGrid1.TextMatrix(x, y) 'Add Text to a Cell


ApExcel.Cells(x, y).Value = Format(MSFlexGrid1.TextMatrix(x, y)) 'Add Text to a Cell

Good Luck!

Author Comment

ID: 8163491
ok, I found it already, this is the code:

ApExcel.Cells(x, y).Value = CDbl(MSFlexGrid1.TextMatrix(x, y))

Author Comment

ID: 8163507
tx for the effort, I tried it too, but yours doesn't work in my program supunr, sorry
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 11

Expert Comment

ID: 8163568
mmm....it seems to be working fine for me even with out the Format function.  What version of Excel do you have?
LVL 11

Accepted Solution

supunr earned 500 total points
ID: 8163610
what if you comment out the line..
ApExcel.Selection.NumberFormat = ""

this will set the number format to the default value which is General.

Author Comment

ID: 8163811
tried it, but doesnt work, but I will accept your answer for the efforts.

Expert Comment

ID: 8165158
It seems as if a bug is in Excel. You can make this experiment:
create a txt file with three lines:
1,01    1.000
1,1     1.000,1
now open excel and import it as tabbed separated file.
Everithing seems fine.
Now close it. Change extension of txt file to xls, and doubvleclick it.
Excel will open it, but you will see spomething strange:
some numbers (thoose with Dot in) looses decimals or they are converted to string format...

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question