Solved

Transfer data from mshgrid in Vb6.0 to excel

Posted on 2004-08-16
2
404 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 Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 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