|
-
Jun 9th, 2001, 06:13 PM
#1
Thread Starter
Junior Member
MS Excell Problems
I need to make a program that will export data from a rich textbox into the cells in MS Excell. I have formatted the textbox so that the data for each cell is seperated by a space ex: hi there would be two different cells, "hi" and "there". If there is any way whatsoever, could someone please tell me how?
-
Jun 9th, 2001, 06:27 PM
#2
Frenzied Member
Here some code i had for excel. If that will help you any.
Code:
Private Sub Form_Load()
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim oRng As Excel.Range
'On Error GoTo Err_Handler
' Start Excel and get Application object.
Set oXL = CreateObject("Excel.Application")
oXL.Visible = True
' Get a new workbook.
Set oWB = oXL.Workbooks.Add
Set oSheet = oWB.ActiveSheet
' Add table headers going cell by cell.
oSheet.Cells(1, 1).Value = Label1
oSheet.Cells(1, 2).Value = Label2
oSheet.Cells(1, 3).Value = Label3
oSheet.Cells(1, 4).Value = Label4
' Format A1:D1 as bold, vertical alignment = center.
With oSheet.Range("A1", "D1")
.Font.Bold = True
.VerticalAlignment = xlVAlignCenter
End With
End Sub
-
Jun 9th, 2001, 06:52 PM
#3
Thread Starter
Junior Member
Thanks for the code, at least i am at least halfway there now
-
Jun 9th, 2001, 07:05 PM
#4
Thread Starter
Junior Member
Now I need to know how to take each part of the text and make it into a different cell. ex: visual basic would be two cells, visual and basic. I already know how to open excell now.
-
Jun 9th, 2001, 07:23 PM
#5
Frenzied Member
Okay can you draw like a little chart or something. Let's say like the last sentence. You would split that into 10 cells. Is that what you are trying to do.
-
Jun 9th, 2001, 07:30 PM
#6
Thread Starter
Junior Member
well, I need each word to have its own cell coing across. so the sentence "hi i am a programmer" would be hi | i | am | a | programmer
-
Jun 9th, 2001, 07:40 PM
#7
Frenzied Member
Alright I am working on it right now. I will post as soon as i am done.
-
Jun 9th, 2001, 07:43 PM
#8
Thread Starter
Junior Member
thanks, if you ever need a program, give me an email, mabe i can help
-
Jun 9th, 2001, 08:17 PM
#9
Frenzied Member
Okay i have not figured it out how to get specific line from the RTF. I will figure it out eventually. You probabably already know. but I created some code to take care of what you are trying to do. Just pass it the text and it will check for the spaces.
Code:
Private Sub Command1_Click()
StartExcel Text1.Text
End Sub
Private Function StartExcel(ByVal Words As String)
Dim sWordsArr() As String
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim oRng As Excel.Range
sWordsArr = Split(Words, Space(1))
'On Error GoTo Err_Handler
' Start Excel and get Application object.
Set oXL = CreateObject("Excel.Application")
oXL.Visible = True
' Get a new workbook.
Set oWB = oXL.Workbooks.Add
Set oSheet = oWB.ActiveSheet
For i = 0 To UBound(sWordsArr)
oSheet.Cells(1, i + 1).Value = sWordsArr(i)
Next
End Function
-
Jun 9th, 2001, 08:22 PM
#10
Thread Starter
Junior Member
-
Jun 9th, 2001, 08:37 PM
#11
Frenzied Member
oSheet.Cells(1, i + 1).Value = sWordsArr(i)
You see where the 1 is where the row is inserted and the i + 1 is because there is no row 0 so you can use option base 1 to start the array at 1. You are welcome.
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
|