PDA

View Full Version : [SOLVED:] Copy from Excel to Word



Regouin
03-22-2005, 03:37 AM
Hi everyone,

Now I am trying to copy a range of cells from Excel to Word, now this is all not very hard to do and I have accomplished that with a little help from the good old kb, but the problem is that i do not want it to appear in a table form as it does normally. Now I can accomplish that by pasting it as a figure but then my hyperlinks in Excel stop working.
Now I have no experience whatsoever on macro's in Word and I prefer the macro to be based within excel. Here is what I have thus far.



Sub PasteToWord()
Dim AppWord As Word.Application
Dim i As Long
Set AppWord = CreateObject("Word.Application")
AppWord.Visible = True
' Change the range to suit your needs. See the How to Use for this code
With Worksheets("hoofd")
i = 6
Do
i = i + 1
Loop Until .Range("A" & i) = ""
.Range("A6:A" & i).SpecialCells(xlCellTypeVisible).Copy
AppWord.Documents.Add
AppWord.Selection.PasteSpecial Link:=False, DataType:=wdPasteMetafilePicture, _
Placement:=wdFloatOverText, DisplayAsIcon:=False
End With
Application.CutCopyMode = False
Set AppWord = Nothing
End Sub

Norie
03-22-2005, 06:23 AM
How do you want it to appear?

Can't you just turn gridlines off?

XL-Dennis
03-22-2005, 07:15 AM
Hi,

Below You find an example on how to achieve it by using bookmark to add a hyperlink to the picture:


Option Explicit
Sub PasteToWord()
Dim AppWord As Word.Application
Dim i As Long
Dim wsSheet As Worksheet
Dim rnData As Range
Set wsSheet = ThisWorkbook.Worksheets("hoofd")
With wsSheet
Set rnData = .Range(.Range("A6"), _
.Range("A65536").End(xlUp).SpecialCells(xlCellTypeVisible))
End With
rnData.Copy
Set AppWord = CreateObject("Word.Application")
With AppWord
.Documents.Add
.Selection.PasteSpecial Link:=False, DataType:=wdPasteMetafilePicture, _
Placement:=wdFloatOverText, DisplayAsIcon:=False
With .ActiveDocument
.Shapes("Picture 2").Select
.Bookmarks.Add ("Test")
.Hyperlinks.Add .Bookmarks("Test").Range, "c:\test.txt"
End With
End With
Application.CutCopyMode = False
AppWord.Visible = True
Set AppWord = Nothing
End Sub


Kind regards,
Dennis