Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-25-2018, 03:36 AM
srinivas.mj srinivas.mj is offline need macro to run on all files in folder Windows 7 32bit need macro to run on all files in folder Office 2007
Novice
need macro to run on all files in folder
 
Join Date: Jan 2018
Posts: 1
srinivas.mj is on a distinguished road
Post need macro to run on all files in folder

need macro to run on all files in folder

Sub BreakLines()
Application.ScreenUpdating = False
With ActiveDocument.Content.Paragraphs
.FirstLineIndent = 0
.LeftIndent = 0
End With
Selection.HomeKey Unit:=wdStory
Do
Selection.EndKey Unit:=wdLine
If Selection.End >= ActiveDocument.Content.End - 1 Then
Exit Do
End If
If Asc(Selection) <> 13 Then


Selection.InsertParagraphAfter
End If
Selection.MoveDown Unit:=wdLine
Loop
Application.ScreenUpdating = True
End Sub
Reply With Quote
  #2  
Old 01-25-2018, 05:10 AM
gmayor's Avatar
gmayor gmayor is offline need macro to run on all files in folder Windows 10 need macro to run on all files in folder Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

See http://www.gmayor.com/document_batch_processes.htm which will handle the folders'

Then change your macro to the following and run it as a custom process.

Code:
Function BreakLines(oDoc As Document) As Boolean
    On Error GoTo err_Handler
    Application.ScreenUpdating = False
    With ActiveDocument.Content.Paragraphs
        .FirstLineIndent = 0
        .LeftIndent = 0
    End With
    Selection.HomeKey Unit:=wdStory
    Do
        Selection.EndKey Unit:=wdLine
        If Selection.End >= ActiveDocument.Content.End - 1 Then
            Exit Do
        End If
        If Asc(Selection) <> 13 Then
            Selection.InsertParagraphAfter
        End If
        Selection.MoveDown Unit:=wdLine
    Loop
    Application.ScreenUpdating = True
    BreakLines = True
lbl_Exit:
    Exit Function
err_Handler:
    BreakLines = False
    Resume lbl_Exit
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Tags
macro, macro vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
need macro to run on all files in folder Failed to apply macro to files in folder Yisrael Word VBA 6 03-25-2017 11:24 PM
Macro to change/convert/delete txt files in folder+subfolders NoS Word VBA 4 03-03-2016 12:10 PM
Macro to replace SSN in all files within a folder caj1980 Word VBA 7 09-11-2014 04:17 PM
need macro to run on all files in folder macro to change name of files in a folder in order expert4knowledge Word VBA 5 07-10-2014 03:54 PM
need macro to run on all files in folder Word Macro - change date in footer for all files in a folder patidallas22 Word VBA 2 03-09-2012 08:14 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:09 PM.


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