Results 1 to 8 of 8

Paste unformatted text into Word via Excel

Threaded View

  1. #1
    Registered User
    Join Date
    03-13-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    15

    Paste unformatted text into Word via Excel

    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
    Last edited by iamtehwalrus; 04-07-2010 at 01:21 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1