![]() |
|
#8
|
||||
|
||||
|
Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String
Dim wdDocSrc As Document, wdDocTgt As Document
Set wdDocTgt = ActiveDocument
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
If strFolder & "\" & strFile <> wdDocTgt.FullName Then
Set wdDocSrc = Documents.Open(FileName:=strFolder & "\" & strFile, _
AddToRecentFiles:=False, Visible:=False)
With wdDocSrc
With .Range
.InsertBefore vbCr
With .Find
.ClearFormatting
.Text = "^13[\*][!^13]@[\*]^13"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
wdDocTgt.Characters.Last.FormattedText = .FormattedText
End With
.Close SaveChanges:=False
End With
End If
strFile = Dir()
Wend
With wdDocTgt.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "[^13]{2,}"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
.Characters.First.Delete
While .Characters.Last.Previous = vbCr
.Characters.Last.Previous = vbNullString
Wend
End With
Set wdDocSrc = Nothing: Set wdDocTgt = 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] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Automation Process of Schedule Report Output and Report Check Score Card ! | ozman86 | Word VBA | 1 | 11-19-2014 11:52 PM |
making translated paragraphs consecutive
|
user2969 | Word | 1 | 01-29-2014 09:00 PM |
Cannot select single characters. Word selects paragraphs or parts of sentences.
|
TMinnich | Word | 2 | 10-25-2013 09:38 AM |
| How to combine many paragraphs in one paragraph? | Jamal NUMAN | Word | 25 | 03-08-2013 04:31 AM |
Making sure the correct number of characters are entered.
|
leroytrolley | Excel | 1 | 07-25-2008 06:38 AM |