Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Copy/Paste Excel Cell Range to Word Bookmark

Hi all.

I am basically looking use my macro to copy a range of cells in excel and
paste them to a bookmarked spot in a word document that my macro opens. I
would like to retain the formatting of the range of cells (so that i am,
effectively, pasting a formatted table into word). I cannot seem to figure
out how to do this, however.

I am using Office 2k3
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Copy/Paste Excel Cell Range to Word Bookmark

I would try the word groups, as they have much more expertise in that field.

But why not try the macro recorder and so how far you get.
--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Dan Thorman" wrote:

Hi all.

I am basically looking use my macro to copy a range of cells in excel and
paste them to a bookmarked spot in a word document that my macro opens. I
would like to retain the formatting of the range of cells (so that i am,
effectively, pasting a formatted table into word). I cannot seem to figure
out how to do this, however.

I am using Office 2k3

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 329
Default Copy/Paste Excel Cell Range to Word Bookmark

Hi Dan,

Here's some code to get you started:

Sub SendRangeToDoc()
Dim wdApp As Word.Application
Dim WdDoc As String
'Copy range
ActiveWorkbook.Sheets(1).Range("A1:J10").Copy
'Establish link to Word
WdDoc = "C:\My Documents\MyFile.doc"
If Dir(WdDoc) < "" Then
Set wdApp = New Word.Application
wdApp.Visible = True
With wdApp
'open the Word Document
Documents.Open Filename:=WdDoc
With wdApp
Dim BmkNm As String
BmkNm = "xlTbl"
With ActiveDocument
If .Bookmarks.Exists(BmkNm) Then
.Bookmarks(BmkNm).Range.PasteSpecial Link:=False, DataType:=wdPasteOLEObject, _
Placement:=wdInLine, DisplayAsIcon:=False
.Save
Else
MsgBox "Bookmark: " & BmkNm & " not found."
End If
End With
End With
End With
Else
MsgBox "File: " & WdDoc & " not found."
End If
'Release Word object
Set wdApp = Nothing
End Sub

However, depending on what you're trying to achieve, you may not need a macro at all. Word is quite capable of linking to a
specified range in an Excel workbook, via a LINK field. With this, the embedded object in Word will update to reflect the current
data in Excel. If your data range in Excel is named, and you use that name in the LINK field, then changing the range the name
applies to in Excel will cause Word to display the new range.

Cheers

--
macropod
[MVP - Microsoft Word]


"Dan Thorman" wrote in message ...
| Hi all.
|
| I am basically looking use my macro to copy a range of cells in excel and
| paste them to a bookmarked spot in a word document that my macro opens. I
| would like to retain the formatting of the range of cells (so that i am,
| effectively, pasting a formatted table into word). I cannot seem to figure
| out how to do this, however.
|
| I am using Office 2k3


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Copy/Paste Excel Cell Range to Word Bookmark

Thanks!!! This line was exactly what i needed:

With ActiveDocument
If .Bookmarks.Exists(BmkNm) Then
..Bookmarks(BmkNm).Range.PasteSpecial Link:=False,
DataType:=wdPasteOLEObject, _
Placement:=wdInLine, DisplayAsIcon:=False

"macropod" wrote:

Hi Dan,

Here's some code to get you started:

Sub SendRangeToDoc()
Dim wdApp As Word.Application
Dim WdDoc As String
'Copy range
ActiveWorkbook.Sheets(1).Range("A1:J10").Copy
'Establish link to Word
WdDoc = "C:\My Documents\MyFile.doc"
If Dir(WdDoc) < "" Then
Set wdApp = New Word.Application
wdApp.Visible = True
With wdApp
'open the Word Document
Documents.Open Filename:=WdDoc
With wdApp
Dim BmkNm As String
BmkNm = "xlTbl"
With ActiveDocument
If .Bookmarks.Exists(BmkNm) Then
.Bookmarks(BmkNm).Range.PasteSpecial Link:=False, DataType:=wdPasteOLEObject, _
Placement:=wdInLine, DisplayAsIcon:=False
.Save
Else
MsgBox "Bookmark: " & BmkNm & " not found."
End If
End With
End With
End With
Else
MsgBox "File: " & WdDoc & " not found."
End If
'Release Word object
Set wdApp = Nothing
End Sub

However, depending on what you're trying to achieve, you may not need a macro at all. Word is quite capable of linking to a
specified range in an Excel workbook, via a LINK field. With this, the embedded object in Word will update to reflect the current
data in Excel. If your data range in Excel is named, and you use that name in the LINK field, then changing the range the name
applies to in Excel will cause Word to display the new range.

Cheers

--
macropod
[MVP - Microsoft Word]


"Dan Thorman" wrote in message ...
| Hi all.
|
| I am basically looking use my macro to copy a range of cells in excel and
| paste them to a bookmarked spot in a word document that my macro opens. I
| would like to retain the formatting of the range of cells (so that i am,
| effectively, pasting a formatted table into word). I cannot seem to figure
| out how to do this, however.
|
| I am using Office 2k3



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
hyperlinking from an Excel cell to a bookmark in Word kipahulu Excel Discussion (Misc queries) 1 July 16th 09 09:41 PM
copy/paste from excel to word including cell color robr Excel Discussion (Misc queries) 0 September 12th 07 03:41 PM
How can I copy and paste from word to excel, w/o being in one cell joster Excel Discussion (Misc queries) 0 June 22nd 07 09:13 PM
Microsoft Word bookmark content into an Excel cell using VBA Gaetan Excel Discussion (Misc queries) 1 March 9th 07 10:21 PM
How to copy cells excel data and paste them under MS Word bookmark Bon Excel Programming 0 January 17th 06 03:36 PM


All times are GMT +1. The time now is 11:03 AM.

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"