#16
|
||||
|
||||
Quote:
Code:
Sub ProcessDocuments() Application.ScreenUpdating = False Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document strDocNm = ActiveDocument.FullName strFolder = GetFolder If strFolder = "" Then Exit Sub strFile = Dir(strFolder & "\*.doc", vbNormal) Do While strFile <> "" If strFolder & "\" & strFile <> strDocNm Then Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False) With ActiveDocument 'wdDoc .ActiveWindow.View.ShowHiddenText = True With .Range .Font.Hidden = True With .Find .ClearFormatting .Replacement.ClearFormatting .Replacement.Font.Hidden = False .Forward = True .Wrap = wdFindContinue .Format = True .Highlight = True .MatchWildcards = True .Text = "" .Replacement.Text = "^&^p" .Execute Replace:=wdReplaceAll .Text = "[^13]{2,}" .Replacement.Text = "^p" .Execute Replace:=wdReplaceAll End With .Copy .PasteSpecial DataType:=wdPasteText End With .Range.Font.Hidden = False .Close SaveChanges:=True End With End If strFile = Dir() Loop Set wdDoc = Nothing Application.ScreenUpdating = True End Sub Function GetFolder() As String Dim oFolder As Object GetFolder = "" Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0) If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path Set oFolder = Nothing End Function
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#17
|
|||
|
|||
Thank you. It would work for the first document but then it would get an error. This is the string it is highlighting that is saying is the error.
.PasteSpecial DataType:=wdPasteText |
#18
|
||||
|
||||
What error?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Copy Text Twice to Paste into word | Albundy | Word | 2 | 09-02-2016 12:59 PM |
Find & selected paras with highlighted text & copy to clipboard | marceepoo | Word VBA | 1 | 09-14-2012 08:20 PM |
Table copy/paste suddenly text-only | mjcoon | Word Tables | 20 | 04-28-2012 08:53 PM |
Can't copy/cut and paste text in Word 2002 | mmiller751 | Word | 0 | 04-17-2012 02:55 PM |
Losing Text box data when copy and paste | Spay | Excel | 0 | 03-15-2011 07:18 AM |