I'm new to VBA. I'm trying to take an excel range and paste it as unformatted text into Word. The problem is I can't figure out how to paste as unformatted text specifically. Everything else works fine.
Sub PasteListToWord(SheetName As String, NumLines As Integer)
Dim WordApp As Object
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
Worksheets(SheetName).Range(Cells(1, 1), Cells(NumLines, 1)).Copy
WordApp.Documents.Add.Content.PasteSpecial DataType:=wdPasteText
Application.CutCopyMode = False
Set WordApp = Nothing
End Sub
Running this says "Compile Error: variable not defined." with wdPasteText highlighted. I tried pasting this way in word and it WORKS, but not in excel
All my code works if I replace the paste line with
WordApp.Documents.Add.Content.Paste
But this isn't what I want since it pastes everything as a table.
Any ideas?
Thanks
EDIT: I should probably mention I'm using Office 2010 Beta :o
Bookmarks