|
-
Feb 8th, 2002, 11:57 AM
#1
Thread Starter
Member
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
-
Feb 8th, 2002, 12:02 PM
#2
Thread Starter
Member
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.
-
Feb 8th, 2002, 12:19 PM
#3
Member
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
-
Feb 8th, 2002, 12:29 PM
#4
Thread Starter
Member
reference the Microsoft Excel 9.0 Object Library
I am not familiar with this, could someone enlighten me
Thanx
-
Feb 8th, 2002, 12:36 PM
#5
Member
VB Menu > Project > References > Microsoft Excel 9.0 Object Library... check it, and click OKay.
newty25
-
Feb 8th, 2002, 02:42 PM
#6
Thread Starter
Member
Thanks for your help with this. Works great!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|