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

Posted on 2003-02-21
Medium Priority
Last Modified: 2010-05-01

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!
Question by:Soontjes
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 7992931

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?


Author Comment

ID: 8002319
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..


Accepted Solution

dmang earned 80 total points
ID: 8025245
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
    End If
    oXLBook.Worksheets("Sheet1").Cells(5, 5) = Text3.Text
    Set oXLBook = Nothing
    Set oXLApp = Nothing


Expert Comment

ID: 8901327
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?
LVL 49

Expert Comment

ID: 8964048
Moderator, my recommended disposition is:

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

DanRollins -- EE database cleanup volunteer

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Suggested Courses

765 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