Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-23-2017, 04:30 PM
eduzs eduzs is offline Speedup my macro Windows 10 Speedup my macro Office 2010 32bit
Expert
Speedup my macro
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default Speedup my macro

I have a code "for each para in actd.para.count" to go through each paragraph, if the paragraph text is not aligned in the center it justify the text, otherwise leaves in the center alignment.
How can i speed up this macro?
Can do this at once with find/found ?
Thanks
__________________
Backup your original file before doing any modification.
Reply With Quote
  #2  
Old 06-23-2017, 04:32 PM
gmaxey gmaxey is offline Speedup my macro Windows 7 32bit Speedup my macro Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Is your code a state secret? Why don't you post it so we can see what your are doing.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 06-23-2017, 05:04 PM
eduzs eduzs is offline Speedup my macro Windows 10 Speedup my macro Office 2010 32bit
Expert
Speedup my macro
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

Sorry, thanks.

Code:
For i = 1 To Selection.Paragraphs.Count

    If Selection.Paragraphs(i).Alignment <> wdAlignParagraphCenter Then Selection.Paragraphs(i).Alignment = wdAlignParagraphJustify

Next i
__________________
Backup your original file before doing any modification.
Reply With Quote
  #4  
Old 06-23-2017, 09:08 PM
gmayor's Avatar
gmayor gmayor is offline Speedup my macro Windows 10 Speedup my macro Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,105
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

The following should work

Code:
Sub Macro1()
Dim oRng As Range
    On Error GoTo lbl_Exit
    Set oRng = ActiveDocument.Range
    With oRng.Find
        .Wrap = wdFindStop
        Do While .Execute(FindText:="^13")
            If Not oRng.ParagraphFormat.Alignment = wdAlignParagraphCenter Then
                oRng.ParagraphFormat.Alignment = wdAlignParagraphJustify
            End If
        Loop
    End With
lbl_Exit:
    Exit Sub
err_Handler:
    Err.Clear
    GoTo lbl_Exit
End Sub
__________________
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
  #5  
Old 06-24-2017, 04:58 AM
eduzs eduzs is offline Speedup my macro Windows 10 Speedup my macro Office 2010 32bit
Expert
Speedup my macro
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

Perfect! Thanks a lot.
__________________
Backup your original file before doing any modification.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Speedup my macro Footnote extraction macro [Why is this macro so slow? / anyway to make it faster?] Le_Blanc Word VBA 10 03-22-2021 11:38 AM
Spell check macro within macro button field doesn't work in one document samuelle Word VBA 0 07-20-2016 02:27 AM
Speedup my macro Macro Question: Need help making a macro to highlight the first word in every sentence LadyAna Word 1 12-06-2014 10:39 PM
Macro Needed to bold specific lines and Macro to turn into CSV anewteacher Word VBA 1 05-28-2014 03:59 PM
custom icon, undo/redo for macro, permanent macro Rapier Excel 0 08-05-2013 06:30 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:41 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