Solved

Transfer data from mshgrid in Vb6.0 to excel

Posted on 2004-08-16
2
403 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 115
How to make an ADE file by code? 11 83
I need help embedding an image as HTML in my vb.net application 3 64
VB 6 error 5 in windows 10 but not in XP 7 55
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…
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 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…

786 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