Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Match the Excel File content with word document Katy Excel Discussion (Misc queries) 4 October 13th 08 03:19 AM
lookup from one document to another and paste in adjacent cell [email protected][_2_] Excel Programming 1 November 1st 07 04:26 AM
Copy Paste from Excel to specified word document raphiel2063 Excel Programming 2 September 12th 07 09:46 AM
How do I paste a Word document into an Excel cell callawayx18 Excel Discussion (Misc queries) 0 January 10th 07 10:46 PM
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 Steven Excel Programming 1 October 17th 05 08:56 AM


All times are GMT +1. The time now is 07:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"