+ Reply to Thread
Results 1 to 2 of 2

Copy a word from a doc to an excel cell - vba

  1. #1
    Registered User
    Join Date
    01-14-2019
    Location
    Szeged
    MS-Off Ver
    MS Office365
    Posts
    1

    Copy a word from a doc to an excel cell - vba

    Hi Guys,

    My problem is the following. The following code finds the text what I want, but I don't know how to copy it in excel cell.

    Private Sub CommandButton1_Click() 'Teszt_2_1

    Dim ws As Worksheet, msWord As Object

    Set ws = ActiveSheet
    Set msWord = CreateObject("Word.Application")

    Dim a As Variant

    For a = 2 To 3

    With msWord
    .Visible = True

    .Documents.Open "C:\Users\mahlj01\Desktop\Egy嶵\Dokumentumkezelő\Excelek_v2\" & Range("A" & a) & ".doc"

    .Activate

    Dim b As Variant
    For b = 2 To 2

    With .ActiveDocument.Content.Find
    .ClearFormatting

    .Text = Worksheets("Teszt_2").Cells(b, 2).Value
    With .Replacement
    .ClearFormatting
    .Font.Bold = True
    .Font.Color = 65280 '12611584
    .Text = Worksheets("Teszt_2").Cells(b, 2).Value
    End With

    .Replacement.Text = Worksheets("Teszt_2").Cells(b, 2).Value
    .Forward = True
    .Wrap = 1 'wdFindContinue (WdFindWrap Enumeration)
    .Format = True
    .MatchCase = False
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=2 'wdReplaceAll (WdReplace Enumeration)

    'While .Excute

    If .Found = True Then
    .Copy

    Worksheets("Teszt_2").Cells(a, 3) =

    End If

    End With

    Next b

    .ActiveDocument.Save
    .ActiveDocument.Close _
    SaveChanges:=wdSaveChanges

    End With

    Next a

    End Sub

    Any idea?

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Copy a word from a doc to an excel cell - vba

    Welcome to the Forum Janos_Mahl!

    I moved your thread from Hello..Introduce Yourself because people do not monitor that subforum for questions.

    Since you are new, I was going to edit your post to add code tags, but there is a hiccup on the site and I can't edit your post. Please add tags around your code. There are two ways to add code tags. One is to select the code part of the text so it is highlighted, then press the "#" button in the edit controls. The other is to simply type in the tags:

    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]


    We have a rule requiring code tags, so please make this change before the thread continues.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ 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. [SOLVED] copy excel cell to cell in word table using excel macro
    By jthurnwps in forum Excel General
    Replies: 1
    Last Post: 07-08-2014, 01:17 AM
  2. Copy Cell Values AND Strings from Excel to Word
    By TeachtheRook in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2014, 08:09 PM
  3. How to copy a Cell from Excel into Word, edit it as RTF and then save back in Excel
    By peterjgoodwin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-10-2013, 06:42 PM
  4. [SOLVED] Copy from excel to a word table to the next available cell in column
    By stojko89 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-17-2012, 01:32 AM
  5. Copy and Paste from Word to Excel Cell
    By Gos-C in forum Excel General
    Replies: 5
    Last Post: 11-04-2008, 03:07 PM
  6. [SOLVED] how do I copy several lines of word text into one excel cell?
    By jhh in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 06-16-2006, 06:25 PM
  7. [SOLVED] How can I copy a list from word into a single cell in excel
    By Hermes in forum Excel General
    Replies: 3
    Last Post: 10-11-2005, 11:05 AM
  8. How can I copy Word data into a merged cell in Excel?
    By Suzan Wild in forum Excel General
    Replies: 1
    Last Post: 06-01-2005, 06:05 PM

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