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
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

621 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