Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2006

Tip: Looking for answers? Try searching our database.

Cursor movement in excel from word (sendkeys?)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DeCock - 12 Sep 2006 14:37 GMT
How can I order the cursor within excel to move one cell to the right or to
copy cells?
After the copy command I would lijke to return to word and paste the cell
value.

Up till a few months ago it worked with sendkeys, but this doesn't seem to
work anymore.
Thank you
Helmut Weber - 12 Sep 2006 17:30 GMT
Hi DeCock,

as in Word, don't move the cursor.

Sub test00001()
' early binding
' excel already running
Dim oExc As Excel.Application
Dim rTmp As Excel.Range
Set oExc = GetObject(, "Excel.application")
Set oWrk = oExc.ActiveWorkbook
Set oSht = oWrk.ActiveSheet
oSht.Cells(1, 1).Activate
Set rTmp = oExc.ActiveCell
MsgBox rTmp.Value              ' for testing
MsgBox rTmp.Offset(0, 1).Value ' for testing
selection.Range.Text = rTmp.Offset(0, 1).Value
End Sub

Activates cell(1,1)
Gives you the value in the next cell of the same row.
Use rTmp.Offset(0, 2).Value for the second next cell etc.

HTH

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

DeCock - 13 Sep 2006 12:41 GMT
Dear Helmut,
Thank you for your help.
I had to make some changes because the application is rather specific, but
it works thanks to you

Best regards

> Hi DeCock,
>
[quoted text clipped - 20 lines]
>
> HTH
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.