• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 141
  • Last Modified:

How to get text from a form in VB to Excel..

Hi,

does anybody know how i can get text that i created in a textbox in VB into Microsoft Excel? I'working with visual studio 6.0. Also i want a printout from the form ( and i don.t know how to do that) and one from te excel document (this should not be a problem).

Thanks for your time!
0
Soontjes
Asked:
Soontjes
1 Solution
 
AKbor75Commented:
soontjes,

you can copy and paste the text, but i guess you don't mean that...?

you're not very clear:
- do you want to create an excel workbook automatically?
- do you want a screendump of the form, or just the text of it in some kind of report format?

ronald
0
 
SoontjesAuthor Commented:
your right i'm not very clear. well i want to create a sort of a report so that i've a nice printout to show other people..

soontjes.
0
 
dmangCommented:
set up a form in vb, with a commandbutton and text box.
add a project reference to your excel object library
(from the main menu Project | references ... and scroll down the list unitl you find it)

add this to the button click event:

'this enters the textbox text in cell 5,5 on
'worksheet "sheet1" in a new workbook

    Dim oXLApp As Excel.Application
    Dim oXLBook As Object
    Dim cRange As Object
   
    Dim c As Object
   
    Set oXLApp = New Excel.Application
   
    'open an existing workbook
    'Set oXLBook = oXLApp.Workbooks.Open("c:\test.xls")
   
    'add a new workbook
    Set oXLBook = oXLApp.Workbooks.Add  
   
    If Err.Number = 0 Then
        oXLApp.WindowState = xlNormal
        oXLApp.Visible = True
    Else
        Err.Clear
    End If
   
    oXLBook.Worksheets("Sheet1").Cells(5, 5) = Text3.Text
   
   
    oXLBook.Close
    Set oXLBook = Nothing
    Set oXLApp = Nothing

0
 
CleanupPingCommented:
Soontjes:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
DanRollinsCommented:
Moderator, my recommended disposition is:

    Accept dmang's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now