Windows 11/10中的 Word 文档中提取所有电子邮件地址(extract all email addresses from Word documents)的教程。如果您有包含多个电子邮件地址的Word文档(DOC、DOCX),并且您想将这些电子邮件地址用于任何目的,那么手动搜索它们真的很累。一个更简单的解决方案是从文档中提取所有电子邮件地址,然后根据需要使用它们。现在,要从Word文档中提取电子邮件地址,您不需要任何第三方解决方案。在本文中,我将展示两个从Word文档中提取电子邮件地址的简单技巧。您可以在Microsoft Word中执行此操作(Microsoft Word)应用。现在就让我们来看看方法吧!
如何从Word文档中提取电子邮件地址(Email Addresses)
Windows 11/10Word文档中提取所有电子邮件地址的两种方法:
- (Extract)使用MS Word中的“(MS Word)高级查找”(Advanced Find)选项提取电子邮件地址。
- 使用 VBA(Use VBA)代码从Word文档中提取所有电子邮件地址。
让我们详细谈谈这些方法!
1]使用MS Word中的(MS Word)高级查找(Advanced Find)选项提取(Extract)电子邮件地址
您可以使用Microsoft Word中的(Microsoft Word)Advanced Find/ Find和替换选项从Word文档中提取所有电子邮件地址。以下是这样做的主要步骤:
- 启动 Microsoft Word。
- 打开包含电子邮件地址的Word文档。(Word)
- 转到“Find > Advanced Find选项。
- 在查找(Find)内容字段中输入一个字符串。
- 启用使用通配符复选框。
- 单击(Click)“查找范围(Find)” > Main Document按钮。
- 返回主文档并使用复制(Copy)选项。
- 创建一个新的空白文档并粘贴复制的电子邮件地址。
现在,让我们详细说明这些步骤吧!
首先,在您的 PC 上运行Microsoft Word应用程序,然后导入包含您要提取的电子邮件地址的Word文档。(Word)
现在,在“主页”(Home)选项卡中,转到“编辑(Editing)”部分,然后单击“查找”( Find)下拉按钮。然后,点击高级查找(Advanced Find)选项。这将打开一个查找和替换(Find and Replace)对话框。
在“查找和替换(Find and Replace)”对话框的“查找”选项卡中,在“(Find)查找内容”(Find what)字段中输入[A-z,0-9]{1,}\@[A-z,0-9,\.]{1,}字符串。
之后,按更多(More)按钮,这将打开各种选项。
接下来,启用使用通配符(Use wildcards)复选框。
然后,单击Find In下拉按钮并选择Main Document选项。
当您这样做时,所有邮件地址将在源Word文档中突出显示并选择,如下面的屏幕截图所示。
现在您要做的是单击“主页”选项卡中的“(Home)复制”(Copy)按钮。或者,您也可以使用复制热键,即Ctrl +C快捷键。它会将Word(Word)文档中存在的所有电子邮件地址复制到剪贴板。
接下来,创建一个空白Word文档或打开记事本(Notepad)应用程序,然后使用专用选项或Ctrl + V热键简单地粘贴复制的电子邮件地址。
您现在可以使用从Word文档中提取的电子邮件地址保存文档,并根据需要使用电子邮件地址。
阅读(Read):如何在 Office 程序中禁用启动画面。
2]使用 VBA(Use VBA)代码从Word文档中提取所有电子邮件地址
您还可以使用简单的Visual Basic for Applications ( VBA ) 代码从Word文档中提取所有电子邮件地址。以下是这样做的主要步骤:
- 打开Word应用程序,然后导入源文档。
- 启动 VBA 编辑器。
- 插入一个新模块。
- 输入(Enter)用于提取电子邮件地址的VBA代码。(VBA)
- 运行VBA代码以提取所有电子邮件地址。
首先,打开Word应用程序,然后导入要从中提取所有电子邮件地址的输入Word文档。(Word)
现在,使用Alt + F11VBA 编辑器(VBA Editor)。如果您已启用主功能区上的“开发人员(Developers)”选项卡,则可以转到“开发人员(Developer)”选项卡并单击“ Visual Basic”选项以打开 VBA 编辑器。
接下来,在VBA 编辑器(VBA Editor)窗口中,转到插入( Insert)菜单并单击模块(Module)选项。
之后,在右侧部分中,在编辑器窗口中输入以下VBA代码:(VBA)
Sub ExtractAllEmailAddressesFromDocument()
Dim strEmailAddresses As String
' Extract all email addresses in a document.
With ActiveDocument.Range
With.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "[A-z,0-9]{1,}\@[A-z,0-9,\.]{1,}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
strEmailAddresses = strEmailAddresses & .Text & ";"
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
' Open a new document to paste the email addresses.
If strEmailAddresses <> "" Then
Documents.Add Template:="Normal", NewTemplate:=False, DocumentType:=0
ActiveDocument.Range.Text = strEmailAddresses
End If
End Sub
然后,转到“运行”(Run)菜单并单击“运行宏”(Run Macros)选项或只需 F5 键。将打开一个宏对话框窗口,您需要在其中选择创建的宏,然后单击(Macros)运行(Run)按钮。
当您单击“运行”(Run)按钮时,将打开一个新的Word文档,其中包含从(Word)Word文档中提取的所有电子邮件地址。
您可以简单地使用提取的电子邮件地址保存文档并根据需要使用它们。
由于Microsoft Word支持多种文档格式,这些电子邮件地址提取方法也可以用于非 Word 文档,例如XML、ODT等。
现在阅读:(Now read:) 使用 Easy Email Extractor 提取电子邮件地址。(Extract email addresses using Easy Email Extractor.)
How to extract Email Addresses from Word document
Here is a tutorial to extract all email addresses from Word documents in Windows 11/10. If you have Word documents (DOC, DOCX) with multiple email addresses and you want to use those email addresses for any purpose, it will be really tiring to manually search for them. An easier solution for you is to extract all email addresses from the document and then use them as you want. Now, to extract email addresses from Word documents, you don’t need any third-party solution. In this article, I am going to show two simple tricks to extract email addresses from Word documents. You can do so in the Microsoft Word application. Let us check out the methods now!
How to extract Email Addresses from Word document
Here are the two methods to extract all email addresses from a Word document in Windows 11/10:
- Extract email addresses using the Advanced Find option in MS Word.
- Use VBA code to extract all email addresses from a Word document.
Let us talk about these methods in detail!
1] Extract email addresses using the Advanced Find option in MS Word
You can use the Advanced Find/ Find and replace option in Microsoft Word to extract all email addresses from Word documents. Here are the main steps to do so:
- Launch Microsoft Word.
- Open a Word document containing email addresses.
- Go to the Find > Advanced Find option.
- Enter a string in the Find what field.
- Enable the Use wildcards checkbox.
- Click on the Find In > Main Document button.
- Return to the main document and use the Copy option.
- Create a new blank document and paste copied email addresses.
Now, let’s elaborate on these steps now!
Firstly, run the Microsoft Word application on your PC and then import a Word document that contains the email addresses that you want to extract.
Now, in the Home tab, go to the Editing section and click on the Find drop-down button. Then, tap on the Advanced Find option. This will open up a Find and Replace dialog box.
In the Find and Replace dialog box, from the Find tab, enter the [A-z,0-9]{1,}\@[A-z,0-9,\.]{1,} string in the Find what field.
After that, press the More button which will open up various options.
Next, enable the Use wildcards checkbox.
Then, click on the Find In drop-down button and select the Main Document option.
As you do that, all the mail addresses will be highlighted and selected in the source Word document, as shown in the below screenshot.
Now what you have to do is that click on the Copy button present in the Home tab. Alternately, you can also use copy hotkey i.e., Ctrl +C shortcut key. It will copy all the email addresses present in the Word document to the clipboard.
Next, create a blank Word document or open the Notepad app and simply paste the copied email addresses using the dedicated option or Ctrl + V hotkey.
You can now save the document with extracted email addresses from the Word document and use the email addresses however you want.
Read: How to disable Splash Screen in Office programs.
2] Use VBA code to extract all email addresses from a Word document
You can also use a simple Visual Basic for Applications (VBA) code in order to extract all email addresses from Word documents. Here are the main steps to do so:
- Open the Word app and then import the source document.
- Launch VBA Editor.
- Insert a new module.
- Enter the VBA code for email address extraction.
- Run the VBA code to extract all email addresses.
First, open the Word app and then import the input Word document from which you want to extract all email addresses.
Now, launch the VBA Editor using the Alt + F11 key combination. If you have enabled the Developers tab on the main ribbon, you can go to the Developer tab and click on the Visual Basic option to open up the VBA Editor.
Next, in the VBA Editor window, go to the Insert menu and click on the Module option.
After that, in the right section, enter the below VBA code in the editor window:
Sub ExtractAllEmailAddressesFromDocument()
Dim strEmailAddresses As String
' Extract all email addresses in a document.
With ActiveDocument.Range
With.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "[A-z,0-9]{1,}\@[A-z,0-9,\.]{1,}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
strEmailAddresses = strEmailAddresses & .Text & ";"
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
' Open a new document to paste the email addresses.
If strEmailAddresses <> "" Then
Documents.Add Template:="Normal", NewTemplate:=False, DocumentType:=0
ActiveDocument.Range.Text = strEmailAddresses
End If
End Sub
Then, go to the Run menu and click on the Run Macros option or simply the F5 key. A Macros dialog window will open up where you need to select the created macro and then click the Run button.
As you click on the Run button, a new Word document will open up with all the extracted email addresses from the Word document.
You can simply save the document with extracted email addresses and use them as required.
As Microsoft Word supports a variety of document formats, these email address extraction methods can be used for a non-Word document too, such as XML, ODT, etc.
Now read: Extract email addresses using Easy Email Extractor.