![]() |
#5
|
|||
|
|||
![]()
Hello Graham,
thank you for helping. I am afraid something went wrong ![]() I received 220 pages, when i tested it on 2 documents ![]() Here is the code i used - I only added the folder function Code:
Option Explicit Sub ParagraphReport() Dim oSource As Document Dim oTbl As Table Dim oTarget As Document Dim oPara As Paragraph Dim oRng As Range Dim strFolder As String Dim strFile As String Application.ScreenUpdating = False Set oTarget = Documents.Add oTarget.PageSetup.Orientation = wdOrientLandscape Set oTbl = oTarget.Tables.Add(oTarget.Range, 1, 2) With oTbl.Rows(1) .Cells(1).Range.Text = " Text Paragraph" .Cells(2).Range.Text = "File Name" End With strFolder = GetFolder strFile = Dir(strFolder & "\*.do*", vbNormal) While strFile <> "" Set oSource = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False) For Each oPara In oSource.Paragraphs Set oRng = oPara.Range oRng.End = oRng.End - 1 If Not oRng.Characters.First = "*" Or Not oRng.Characters.Last = "*" Then With oTbl .Rows.Add .Rows.Last.Range.Cells(1).Range.Text = oPara.Range.Text .Rows.Last.Range.Cells(2).Range.Text = oSource.Name End With End If Next oPara oSource.Close wdDoNotSaveChanges DoEvents strFile = Dir() Wend lbl_Exit: Set oSource = Nothing Set oPara = Nothing Set oRng = Nothing Set oTarget = Nothing Set oTbl = Nothing Application.ScreenUpdating = True Exit Sub End Sub Function GetFolder() As String 'Found on a forum 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 dan |
|
![]() |
||||
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 |
![]() |
user2969 | Word | 1 | 01-29-2014 09:00 PM |
![]() |
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 |
![]() |
leroytrolley | Excel | 1 | 07-25-2008 06:38 AM |