Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-28-2016, 09:06 PM
gmayor's Avatar
gmayor gmayor is offline Calling Sub Routine for Formatting recently Created Word Document Windows 10 Calling Sub Routine for Formatting recently Created Word Document Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,138
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 ofgmayor has much to be proud of
Default


Either way, you should make some small changes to the macro to run it from another application e.g. as follows - call it with MyReplacements wdDoc

Code:
Sub MyReplacements(oDoc As Object)
'A basic Word macro coded by Greg Maxey
'as modified by Graham Mayor ;)
Dim arrTerms() As String
Dim oRng As Object
Dim lngIndex As Long
    arrTerms = Split("(\<italics\>)(*)(\<italics/\>)|(\<bold\>)(*)(\<bold/\>)|(\<indent\>)(*)(\<indent/\>)", "|")
    For lngIndex = 0 To UBound(arrTerms)
        Set oRng = oDoc.Range
        With oRng.Find
            .Text = arrTerms(lngIndex)
            .MatchWildcards = True
            Select Case lngIndex
                Case 0: .Replacement.Font.Italic = True
                Case 1: .Replacement.Font.Bold = True
                Case 2: .Replacement.ParagraphFormat.LeftIndent = 72
            End Select
            .Replacement.Text = "\2"
            .Execute Replace:=2
        End With
    Next
lbl_Exit:
    Set oRng = Nothing
    Set oDoc = Nothing
    Exit Sub
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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding tables to Created word document whilst other word document open Help rpb925 Word VBA 18 03-30-2016 04:45 PM
Calling Sub Routine for Formatting recently Created Word Document Uploading a previously created bibliography to be used in a new document JennJenn79 Word 1 07-16-2015 09:34 PM
Calling Sub Routine for Formatting recently Created Word Document was document created using 2010 or 2013 TDOG Word 1 10-12-2014 03:37 PM
Copy format created by a conditional formatting spk Excel 2 04-10-2013 04:41 AM
Word crashing on "sort" routine Kayale Word 0 04-12-2010 04:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:57 AM.


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