View Single Post
 
Old 06-15-2018, 11:31 AM
klutch klutch is offline Windows 7 32bit Office 2016 for Mac
Advanced Beginner
 
Join Date: Jun 2018
Posts: 31
klutch is on a distinguished road
Default

Code:
Sub CopyAndPaste()
Dim myfile, wdApp As New Word.Application, wdDoc As Word.Document
myfile = Application.GetOpenFilename(, , "Browse for Document")
Dim i As Integer
i = Application.Match("Avg", Sheet1.Range("A1:A20"), 0)
Range("E" & i).Select
Selection.Copy

wdApp.Visible = True
Set wdDoc = wdApp.Documents.Open(myfile)
'select the word range you want to paste into
  If Range("c2") = 22 Then wdDoc.Bookmarks("d22").Select
 Dim bk As Bookmark
    For Each bk In ActiveDocument.Bookmarks
        Dim r As Range
        Set r = bk.Range
        r.InsertAfter = "below"
    Next
  If Range("c2") = 5 Then wdDoc.Bookmarks("d5").Select
   For Each bk In ActiveDocument.Bookmarks
        
        r.InsertAfter = "below"
    Next
  
  If Range("c2") = -20 Then wdDoc.Bookmarks("d20").Select
   For Each bk In ActiveDocument.Bookmarks
    
        
        r.InsertAfter = "below"
    Next
  
    
    
    'and paste the clipboard contents
    wdApp.Selection.Paste
End Sub
Here is how I tried to implement. It is still just replacing the bookmark instead of pasting it below
Reply With Quote