![]() |
|
#1
|
|||
|
|||
![]()
Greg,
That is mind boggling. It's so concise. Thanks heaps The eyes bleeding was a good burn by the way. So the code works perfectly when I run as a normal macro in a word document but when I try and call it from my vba in access for a nearly created word document its not working so I don't believe I am calling it correctly or it isn't being referenced. I have saved the script in a module. Then I call the sub routine. The script runs but nothing happens. So I think it is the following line that might not be referencing the document correctly as I am not in the document as such it has just been created and is being filled with text using VBA. Is there any other way to reference the newly created word document. Your reference Code:
Set oRng = ActiveDocument.Range Code:
'Create a new document Set wdDoc = .Documents.Add With wdDoc Thanks. |
#2
|
||||
|
||||
![]()
Nah, it's verbose!
![]() Code:
Sub Demo() Dim arrTerms(), i As Long arrTerms = Array("italics", "bold", "indent") With ActiveDocument.Range.Find .MatchWildcards = True .Replacement.Text = "\3" For i = 0 To UBound(arrTerms) .Replacement.ClearFormatting .Text = "(\<" & arrTerms(i) & ")(\>)(*)\1/\2" Select Case i Case 0: .Replacement.Font.Italic = True Case 1: .Replacement.Font.Bold = True Case 2: .Replacement.ParagraphFormat.LeftIndent = 72 End Select .Execute Replace:=wdReplaceAll Next End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
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 |
![]() |
JennJenn79 | Word | 1 | 07-16-2015 09:34 PM |
![]() |
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 |