CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2012
    Posts
    2

    How to extract on screen data.

    Hello

    I have this VB 6 application with about 400 records, it takes forever to extract to an excell sheet.
    Is ther an easy way to get everything into a string or directly into excell? (Maybe clipboard and then Past it.)
    I have Visual Basic Express installed.

    Name:  temp.JPG
Views: 657
Size:  83.7 KB

    Thank you

  2. #2
    Join Date
    May 2002
    Location
    Boston
    Posts
    67

    Re: How to extract on screen data.

    Hi,

    I'm not sure if this applies. Just load the data into an array and copy to a range in excel

    Code:
    Imports Microsoft.Office.Interop
    
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    
            Dim xlApp As Excel.Application
            Dim ws As Excel.Worksheet
    
            Dim wb As Excel.Workbook
    
            Dim data(20, 20) As Double
            Dim j, k As Integer
    
            Try
    
                xlApp = New Excel.Application
                xlApp.UserControl = True 'False
                xlApp.Visible = True 'False
    
                
                xlApp.Workbooks.Add()
                wb = xlApp.ActiveWorkbook
    
                ws = wb.Worksheets(1)
    
                For j = 0 To 20
                    For k = 0 To 20
                        data(j, k) = j * k
                    Next k
                Next j
    
                ws.Range("A1").Resize(20, 20).Value = data
    
            Catch ex As Exception
    
            End Try
        End Sub
    End Class
    Curt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured