Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 04-09-2023, 05:31 AM
gmayor's Avatar
gmayor gmayor is offline How to copy text from Word to Excel according to a list? Windows 10 How to copy text from Word to Excel according to a list? Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Change the main macro as follows and enter the names to search in the array.
Code:
Option Explicit

Private Const xlWB As String = "C:\Path\Empty Excel File name.xlsx"
Private Const xlSheet As String = "Sheet1"
Private vList() As Variant

Sub ExtractText()
    vList = Array("Speaker 1", "Speaker 2", "Speaker 3")
    Dim oDoc As Document
    Dim oRng As Range
    Dim i As Long

    Set oDoc = ActiveDocument
    Set oRng = oDoc.Range
    With oRng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Font.Name = "Times New Roman"
        .Font.Bold = True
        Do While .Execute()
            For i = 0 To UBound(vList)
                If oRng.Text = CStr(vList(i)) Then
                     WriteToWorksheet xlWB, xlSheet, oRng.Text
                    Exit For
                 End If
            Next i
        Loop
    End With
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 

Tags
excel copy text, word macro



Similar Threads
Thread Thread Starter Forum Replies Last Post
Text To Copy From Excel To Relevant Word Document Covert Codger Word VBA 4 07-27-2022 11:40 PM
How to copy text from Word to Excel according to a list? how to copy different text from word into excel on consecutive rows mihnea96 Word VBA 4 05-08-2017 12:09 PM
how to copy addresses in word document to excel/mailmerge list msnarayanan Mail Merge 4 10-17-2015 03:17 PM
Copy Underline text from Word and Paste into excel rfaris Excel Programming 7 10-05-2015 05:56 AM
How to copy text from Word to Excel according to a list? copy a specific words to excel list romanticbiro Word VBA 12 12-03-2014 05:12 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:46 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft