Results 1 to 6 of 6

Thread: Export textbox to Excel

  1. #1

    Thread Starter
    Member dmerchen's Avatar
    Join Date
    Mar 2001
    Location
    Moving Back to Texas
    Posts
    60

    Export textbox to Excel

    I have looked over the forum for a simple export to Excel spreadsheet, but haven't found the right thing yet. What is a simple way to export information from a text box to a particular cell in Excel(A1)?

    Any ideas would be appreciated.

    Thanx
    DMerchen

  2. #2

    Thread Starter
    Member dmerchen's Avatar
    Join Date
    Mar 2001
    Location
    Moving Back to Texas
    Posts
    60
    oh yeah, there is one other qualifier, I wanted to open a particular excel file. For example c:\mydocuments\myexcel.xls then write to the cell(A1). That might explain it better.
    DMerchen

  3. #3
    Member
    Join Date
    Nov 2001
    Location
    Virginia
    Posts
    58
    Try this...

    Code:
    Private Sub Command1_Click()
        Dim XLApp As Excel.Application
        Dim wrkWorkbook As Excel.Workbook
        Dim wrkSheet As Excel.Worksheet
        
        Set XLApp = CreateObject("Excel.Application")
        XLApp.Workbooks.Open ("c:\mydocuments\myexcel.xls")
        Set wrkWorkbook = XLApp.ActiveWorkbook
        Set wrkSheet = wrkWorkbook.ActiveSheet
        
        XLApp.Visible = False
        
        wrkSheet.Range("A1").Select
        Selection = txtBox.Text
        
        wrkWorkbook.Close True
        Set wrkSheet = Nothing
        Set wrkWorkbook = Nothing
        Set XLApp = Nothing
    End Sub
    Make sure you reference the Microsoft Excel 9.0 Object Library... it won't work unless you do.

    Good Luck!
    newty25

  4. #4

    Thread Starter
    Member dmerchen's Avatar
    Join Date
    Mar 2001
    Location
    Moving Back to Texas
    Posts
    60
    reference the Microsoft Excel 9.0 Object Library

    I am not familiar with this, could someone enlighten me

    Thanx
    DMerchen

  5. #5
    Member
    Join Date
    Nov 2001
    Location
    Virginia
    Posts
    58
    VB Menu > Project > References > Microsoft Excel 9.0 Object Library... check it, and click OKay.

    newty25

  6. #6

    Thread Starter
    Member dmerchen's Avatar
    Join Date
    Mar 2001
    Location
    Moving Back to Texas
    Posts
    60
    Thanks for your help with this. Works great!
    DMerchen

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