Hello!
I'm attempting to copy a range from Excel and paste into a blank word document. The following code works up to the point where the pasting should occur. If I run the macro a new word documents open but it remains blank. The data is copied and makes it to the clipboard but won't paste unless done manually. Any ideas? I'm running Excel for Mac 2017. Here's the code (I need the filter later but am just using it with dummy data now):
I'm attempting to copy a range from Excel and paste into a blank word document. The following code works up to the point where the pasting should occur. If I run the macro a new word documents open but it remains blank. The data is copied and makes it to the clipboard but won't paste unless done manually. Any ideas? I'm running Excel for Mac 2017. Here's the code (I need the filter later but am just using it with dummy data now):
Code:
Sub PasteToWord()
Dim wApp As Word.Application
Dim wDoc As Word.Document
On Error Resume Next
Set wApp = New Word.Application
wApp.Visible = True
Documents.Add DocumentType:=wdNewBlankDocument
wDoc.Content.InsertAfter Range("A1")
Range("A1:A4").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$A$4").AutoFilter Field:=14, Criteria1:=RGB(255 _
, 0, 0), Operator:=xlFilterCellColor
Selection.Copy
wDoc.Activate
Selection.Paste
End Sub
Last edited: