Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Paste non-adjacent cell content from Excel to open Word document
Hi
There are many posts here addressing this subject but my particular requirement is to paste from Excel to an existing open Word template. The Word filename will be variable. I will have the cursor positioned at the insertion point in the Word template and want to Alt, Tab, select and paste non-adjacent cells (known OFFSET is always 0, 11) from my Excel workbook and paste as unformatted text into Word. When I try this manually, I always get the intervening cell content as well so Im guessing 2 copy/paste events are needed. BTW, I€˜m using 2003. Thanks in advance |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Paste non-adjacent cell content from Excel to open Word document
I'd paste an intermediate copy into a new worksheet. Then copy|Paste from there
into MSWord. Jimbob wrote: Hi There are many posts here addressing this subject but my particular requirement is to paste from Excel to an existing open Word template. The Word filename will be variable. I will have the cursor positioned at the insertion point in the Word template and want to Alt, Tab, select and paste non-adjacent cells (known OFFSET is always 0, 11) from my Excel workbook and paste as unformatted text into Word. When I try this manually, I always get the intervening cell content as well so Im guessing 2 copy/paste events are needed. BTW, I€˜m using 2003. Thanks in advance -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Paste non-adjacent cell content from Excel to open Word docume
Thanks for that Dave and it works a treat.
The question remains, how to switch to the open Word document. I need to copy data repeatedly from selected elements of the workbook. Its this swapping which is the main stumbling block. Regards |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Paste non-adjacent cell content from Excel to open Word docume
If you're controlling MSWord from excel, you can use something like:
Option Explicit Sub testme() 'Dim WDApp As Word.Application 'Dim WDDoc As Word.Document Dim WDApp As Object Dim WDDoc As Object Dim myDocName As String Dim WordWasRunning As Boolean Dim testStr As String myDocName = "C:\my documents\word\doc10.doc" testStr = "" On Error Resume Next testStr = Dir(myDocName) On Error GoTo 0 If testStr = "" Then MsgBox "Word file not found!" Exit Sub End If WordWasRunning = True On Error Resume Next Set WDApp = GetObject(, "Word.Application") If Err.Number < 0 Then Set WDApp = CreateObject("Word.Application") WordWasRunning = False End If WDApp.Visible = True 'at least for testing! Set WDDoc = WDApp.documents.Open(Filename:=myDocName) 'your code do to the copy|paste to a new sheet. 'then your code to do the copy from that new sheet to MSWord. 'If WordWasRunning Then ' 'leave it running 'Else ' WDApp.Quit 'End If Set WDDoc = Nothing Set WDApp = Nothing End Sub You may want to add a bookmark in your word document where the data gets pasted, then use that bookmark. I don't automate MSWord enough to help you with that portion. If you don't get a response here, I'd suggest asking in an MSWord newsgroup. Be sure to include that you're automating MSWord from excel--and what version of MSOffice you're using. Jimbob wrote: Thanks for that Dave and it works a treat. The question remains, how to switch to the open Word document. I need to copy data repeatedly from selected elements of the workbook. Its this swapping which is the main stumbling block. Regards -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Match the Excel File content with word document | Excel Discussion (Misc queries) | |||
lookup from one document to another and paste in adjacent cell | Excel Programming | |||
Copy Paste from Excel to specified word document | Excel Programming | |||
How do I paste a Word document into an Excel cell | Excel Discussion (Misc queries) | |||
copy multiple worksheets of a workbook, and paste onto a Word document ( either create new doc file or paste onto an existing file.) I need this done by VBA, Excel Macro | Excel Programming |