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 / February 2006

Tip: Looking for answers? Try searching our database.

Macro to automate copying text from Word doc to Excel spreadsheet

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bev - 24 Feb 2006 14:49 GMT
I would like to automate the copying of text from Word to an Excel cell.  
Each time, the text selection would be different from the previously selected
text, and the destination cell in Excel would also be different.  The text
length is also variable.  Ideally, the macro should contain the steps to copy
the highlighted text in the Word document, navigate to the open Excel
spreadsheet and paste the text into the cell that already has focus.  By
pressing Enter, the focus is passed to the cell underneath.  The macro should
then also record the step to navigate back to the Word document.  That would
then be the end of the macro.
Cindy M  -WordMVP- - 28 Feb 2006 18:13 GMT
Hi =?Utf-8?B?QmV2?=,

> I would like to automate the copying of text from Word to an Excel cell.  
> Each time, the text selection would be different from the previously selected
[quoted text clipped - 5 lines]
> then also record the step to navigate back to the Word document.  That would
> then be the end of the macro.

See if this does what you need

Sub CopySelectionToExcel()
   Dim xlApp As Object
   
   On Error Resume Next
   Set xlApp = GetObject(, "Excel.Application")
   If Err.Number = 429 Then
       MsgBox "Excel is not running. The macro cannot continue"
       Exit Sub
   End If
   On Error GoTo 0
   Selection.Copy
   xlApp.ActiveSheet.Paste
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

Rate this thread:






 
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.