![]() |
#1
|
|||
|
|||
![]()
Greetings all,
Sorry to hear the Server deleted all the threads. I am posting again. I am looking to check my documents for specific type of formatting. Each paragraph first character is a star * Paragraph Last character is a star * What I am trying to do is loop through documents. If a paragraph does not start or end with a star Copy that paragraph to a table. My vba is not very good but i have come up with the idea, the code does not work understandably. Code:
Sub ParagraphReport() Dim aSource As Document Dim aTbl As Table Dim aTarget As Document Dim oPara As Paragraph Dim strFolder As String Dim strFile As String Application.ScreenUpdating = False Set aTarget = Documents.Add aTarget.PageSetup.Orientation = wdOrientLandscape Set aTbl = oTarget.Tables.Add(oTarget.Range, 1, 2) With aTbl.Rows(1) .Cells(1).Range.Text = " Text Paragraph" .Cells(2).Range.Text = "File Name" strFolder = GetFolder strFile = Dir(strFolder & "\*.do*", vbNormal) While strFile <> "" Set aSource = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False) '***** Below is problem area For Each oPara In ActiveDocument.Paragraphs If NOT InStr(1, oPara.Range.Text.First, "*") > 0 AND If InStr(1, oPara.Range.Text.Last, "*") > 0 Then oPara.add '***** End If Next oPara With aTbl .Rows.Add .Rows.Last.Range.Cells(1).Range.Text = aSource.oPara.Range.Text .Rows.Last.Range.Cells(2).Range.Text = aSoource.strFile.Range.Text End With oSource.Close wdDoNotSaveChanges strFile = Dir() Wend Set aSource = Nothing Application.ScreenUpdating = True lbl_Exit: Exit Sub End 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 is this possible? dan88 |
|
![]() |
||||
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 |