jazzyt2u
07-03-2008, 02:05 PM
I tried looking through the boards for the following and couldn't get the answer.
From another post I tried the following to open word from excel and to go to a bookmark to then paste the data from excel. It all works except when I get to the bookmark.
I get a run-time error "5101":
The bookmark doesn't exist.
When I click on the word document and check, it's there....
I don't know if the coding is directing it to look in the correct place.
Please help.
BTW once I get it to go to the bookmark I plan to paste the data from excel.
Also how do I copy my coding into this forum like it looks in VBE? LOL :dunno
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 7/3/2008 by ISR
'
'
Dim wdApp As Object
Dim wdDoc As Object
Dim BMRange As Range
Range("B5").Select
Dim rngT10 As Range
Dim rngD10 As Range
Dim rngTD10 As Range
Set rngT10 = Selection
ActiveCell.Offset(2, 0).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 8).Select
Set rngD10 = Selection
Set rngTD10 = Range(rngT10, rngD10)
Set wdApp = CreateObject("Word.Application") 'Create an instance of word
wdApp.Application.Visible = True
Set wdDoc = wdApp.Documents.Open("S:\TashaA\TestAvon.doc") 'Open word file
rngTD10.Copy
Set BMRange = wdDoc.Goto(what:=wdGoToBookmark, Name:="PlaceHolder1")
Selection.PasteExcelTable False, False, False
Set wdDoc = Nothing
End Sub
Thanks,
jazzyt2u: pray2:
From another post I tried the following to open word from excel and to go to a bookmark to then paste the data from excel. It all works except when I get to the bookmark.
I get a run-time error "5101":
The bookmark doesn't exist.
When I click on the word document and check, it's there....
I don't know if the coding is directing it to look in the correct place.
Please help.
BTW once I get it to go to the bookmark I plan to paste the data from excel.
Also how do I copy my coding into this forum like it looks in VBE? LOL :dunno
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 7/3/2008 by ISR
'
'
Dim wdApp As Object
Dim wdDoc As Object
Dim BMRange As Range
Range("B5").Select
Dim rngT10 As Range
Dim rngD10 As Range
Dim rngTD10 As Range
Set rngT10 = Selection
ActiveCell.Offset(2, 0).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 8).Select
Set rngD10 = Selection
Set rngTD10 = Range(rngT10, rngD10)
Set wdApp = CreateObject("Word.Application") 'Create an instance of word
wdApp.Application.Visible = True
Set wdDoc = wdApp.Documents.Open("S:\TashaA\TestAvon.doc") 'Open word file
rngTD10.Copy
Set BMRange = wdDoc.Goto(what:=wdGoToBookmark, Name:="PlaceHolder1")
Selection.PasteExcelTable False, False, False
Set wdDoc = Nothing
End Sub
Thanks,
jazzyt2u: pray2: