Solved

Transfer data from mshgrid in Vb6.0 to excel

Posted on 2004-08-16
2
400 Views
Last Modified: 2008-01-09
Can some tell me (give the code to transfer data from mshgrid to excel file).

Thank you.
0
Comment
Question by:Aiysha
2 Comments
 
LVL 5

Expert Comment

by:LordRipper
ID: 11810608
Hi Aiysha,
I found this webpage whith the code on but I cant seem to understand the language but I can make out the code
here is the link
http://66.102.9.104/search?q=cache:ocoART8XAYkJ:www.fesppr.br/~lecheta/Visual%2520Basic/Apostilas/dicasVB%25206.doc+vb6+mshgrid+to+excel&hl=en
Cheers!
0
 
LVL 5

Accepted Solution

by:
Z03niE earned 500 total points
ID: 11827211
First of all make sure you add Excell Object Library into you project reference.And here's the code

'First off declare some variables
Private objExcel As Excel.Application
Private objWorkbook As Excel.Workbook

private sub Flex2Excel()
   Dim I, N As Integer
   Set objExcel = CreateObject("Excel.Application")
   Set objWorkbook = objExcel.Workbooks.Add

   For I = 0 To MSFlexGrid1.rows - 1             'Filling all the Flexgrid content to the excel worksheet
    For N = 0 To MSFlexGrid1.Cols                 'is the number of the Flexgrid's column
        objWorkbook.ActiveSheet.Cells(I + 1, N + 1).Value = MSFlexGrid1.TextMatrix(I, N)    'the part to transfer flexgrid value to Excel
    Next N
   Next I
objExcel.Visible = True                                 'Show the Excel that contain the result ,comment it if you want to save the Excell without showing it
'    objWorkbook.SaveAs "c:\Flex2Excel.xls"       ' uncomment this part if you want to save the file

'Clean everything up
Set objWorkbook = Nothing
Set objExcel = Nothing
end sub
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now