Danny Osborne
asked on
vba copy excel range to bookmark in word
Hi,
Can anyone help me with some vba code to copy and excel range to bookmark in word?
I have the following but it xthrows a runtime error at ".Bookmark("Paste_table"). Selection. Paste"
Private Sub WordExpcmd_Click()
Dim appWord As Object, docWord As Object
Dim lngRow As Long, lngRowCount As Long
Set appWord = CreateObject("Word.Applica tion")
Set docWord = appWord.Documents.Open("C: \Documents and Settings\taqdjo\Desktop\Ma in work tree\Statistical reports\Weekly Manually created reports\test delete.doc")
Range("A1:G98").Select
With docWord
.Bookmark("Paste_table").S election.P aste
.Close
End With
Set docWord = Nothing
appWord.Quit
Set appWord = Nothing
End Sub
Danny
Can anyone help me with some vba code to copy and excel range to bookmark in word?
I have the following but it xthrows a runtime error at ".Bookmark("Paste_table").
Private Sub WordExpcmd_Click()
Dim appWord As Object, docWord As Object
Dim lngRow As Long, lngRowCount As Long
Set appWord = CreateObject("Word.Applica
Set docWord = appWord.Documents.Open("C:
Range("A1:G98").Select
With docWord
.Bookmark("Paste_table").S
.Close
End With
Set docWord = Nothing
appWord.Quit
Set appWord = Nothing
End Sub
Danny
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Teylyn,
Thanks for this!! It kinda works, but I can only get one cell rather than the range I require to display in the word document. If I set the range as follows -
Set Paste_table = Sheet1.Range("A1")
It works fine. However, if i increase the range of cells as below, or even just to a range of a single row with 5 cells, I get a runtime error (13): type mismatch
Set Paste_table = Sheet1.Range("A1:G7")
Why might this be?
Danny
Thanks for this!! It kinda works, but I can only get one cell rather than the range I require to display in the word document. If I set the range as follows -
Set Paste_table = Sheet1.Range("A1")
It works fine. However, if i increase the range of cells as below, or even just to a range of a single row with 5 cells, I get a runtime error (13): type mismatch
Set Paste_table = Sheet1.Range("A1:G7")
Why might this be?
Danny
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks all, this is working now!!
Open in new window