Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-29-2016, 07:17 AM
dan88 dan88 is offline Making a Paragraph Report - Check Paragraphs For First & Last Characters Windows 10 Making a Paragraph Report - Check Paragraphs For First & Last Characters Office 2016
Novice
Making a Paragraph Report - Check Paragraphs For First & Last Characters
 
Join Date: Feb 2016
Posts: 24
dan88 is on a distinguished road
Default Making a Paragraph Report - Check Paragraphs For First & Last Characters

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
Please advise and many many thanks for helping.

is this possible?



dan88
Reply With Quote
 



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 a Paragraph Report - Check Paragraphs For First &amp; Last Characters making translated paragraphs consecutive user2969 Word 1 01-29-2014 09:00 PM
Making a Paragraph Report - Check Paragraphs For First &amp; Last Characters 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 a Paragraph Report - Check Paragraphs For First &amp; Last Characters Making sure the correct number of characters are entered. leroytrolley Excel 1 07-25-2008 06:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:10 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft