+ Reply to Thread
Results 1 to 2 of 2

VBA Automation -Open a Word File, Copy Text, Paste into a Cell

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    New Mexico
    MS-Off Ver
    Excel 2007
    Posts
    10

    VBA Automation -Open a Word File, Copy Text, Paste into a Cell

    Good afternoon all,

    I am having trouble automating Word in order to open a word file, copy all of the containing text and pasting it into my excel sheet range. The macro is bugging out at the ".Selection.Copy" portion of the code with the error message "Object doesn't support this property or method." So now I'm kind of stuck. I'm trying to import data from a word file into excel. Can anyone take a look and see what may be going on? I do have the word properties library enabled as well.

    Sub MakeMemos()
    ' Creates memos in word using Automation
    Dim WordApp As Object
    Dim Data As Range, message As String
    Dim Records As Integer, i As Integer
    Dim Region As String, SalesAmt As String, SalesNum As String
    Dim SaveAsName As String
    ' Start Word and create an object (late binding)
    Set WordApp = CreateObject("Word.Application")
    ' Information from worksheet
    Set Data = Sheets("Sheet1").Range("A1")
    message = Sheets("Sheet1").Range("A2")
    ' Cycle through all records in Sheet1



    ' Determine the filename
    SaveAsName = "C:\Users\adam\Desktop\test.docx"







    With WordApp
    .Documents.Open ("C:\Users\adam\Desktop\test.docx")
    With WordApp.Selection.Document

    .Selection.Copy

    End With
    .ActiveDocument.SaveAs Filename:=SaveAsName
    End With

    ' Kill the objectd
    WordApp.Quit
    Set WordApp = Nothing

    Range("A11").select
    Selection.Paste


    End Sub

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: VBA Automation -Open a Word File, Copy Text, Paste into a Cell

    Hi,

    Please wrap your code inside CODE tag as the forum rules, it will be easier for others to read and copy your code.

    Try to change the code to this one :

    Please Login or Register  to view this content.
    Regards
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 10-29-2014, 10:48 AM
  2. [SOLVED] VBA code to open many files, copy text, close file, paste text in second work
    By Bikeman in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 02-11-2014, 12:59 PM
  3. Replies: 13
    Last Post: 11-29-2012, 08:25 PM
  4. [SOLVED] open variably named file, copy/paste data into consolidation file, open next file in list
    By sllawrence1968 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-29-2012, 09:49 PM
  5. Replies: 1
    Last Post: 10-17-2005, 04:05 AM

Tags for this Thread

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