View Single Post
 
Old 06-15-2018, 12:56 PM
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

Like this?
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
    Dim r As Range
    If Range("c2") = 22 Then wdDoc.Bookmarks("d22").Select
         Set r = Selection.Range
         r.Collapse wdCollapseEnd
         wdApp.Selection.Collapse wdCollapseEnd
wdApp.Selection.Paste
    End If
     If Range("c2") = 5 Then wdDoc.Bookmarks("d5").Select
         Set r = Selection.Range
         r.Collapse wdCollapseEnd
         wdApp.Selection.Collapse wdCollapseEnd
wdApp.Selection.Paste
   End If
    If Range("c2") = -20 Then wdDoc.Bookmarks("d20").Select
         Set r = Selection.Range
         r.Collapse wdCollapseEnd
         
         wdApp.Selection.Collapse wdCollapseEnd
wdApp.Selection.Paste
    End If
End Sub
still getting error :/
Reply With Quote