Send Text String

B

Benz

Hi,

I have a toolbar that contains a textbox - im trying to have it copy the
text to the first empty cell in an existing excel doc. I have most of it
complete but im having trouble actually getting the data over to excel.

THis is (part) the code I was trying that obviously isint correct:

Set oWB = oXL.Workbooks.Open(FileName:=WorkbookToWorkOn)

Sheets("ToDos").Cells(Cells(Rows.Count, 1) _
.End(xlUp).Row, 1).Offset(1, 0) = Paste


I would apprecaite any help!

Ben Z.
 
H

Helmut Weber

Hi Ben,

given that the rest of you code is working:

Sub Macro12()
' early binding
' excel already running
Dim sendbar As CommandBar
Dim sendbox As CommandBarControl
Set sendbar = Application.CommandBars("Custom01")
Set sendbox = sendbar.Controls(1)
Dim oXlc As Excel.Application
Dim oWrk As Excel.Workbook
Dim oSht As Excel.Worksheet
Set oXlc = GetObject(, "Excel.application")
Set oWrk = oXlc.Workbooks.Open("c:\test\Excel\liste2.xls")
Set oSht = oWrk.Worksheets(1)
oSht.Cells(1, 1).Value = sendbox.Text
End Sub

Without loooking it all up myself,
I wouldn't know whether it makes sense or is correct.

Where should the text from the sendbox go to?
Cells(Cells(Rows.Count, 1).End(xlUp).Row, 1).Offset(1, 0)

in any case, before "cells" the object it refers to is missing.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top