![]() |
#12
|
||||
|
||||
![]()
I've just run the following test macro on the document you uploaded:
Code:
Sub Test() Dim StrRep As String, wdDoc As Document StrRep = Format(DateAdd("d", -1, CDate(Month(Now()) & "/1/" & Year(Now()))), "MMMM D, YYYY") Set wdDoc = ActiveDocument With wdDoc With .Range.Find .ClearFormatting .Replacement.ClearFormatting .Forward = True .Wrap = wdFindStop .Format = False .MatchWildcards = True .Replacement.Text = StrRep .Text = "[ADJMO][abceghlmnorstuy]{2,7} 31, [12][0-9]{3}" .Execute Replace:=wdReplaceAll .Text = "February 2[89], [12][0-9]{3}" .Execute Replace:=wdReplaceAll .Text = "[AJSN][beilmnoprtuv]{4,8} 30, [12][0-9]{3}" .Execute Replace:=wdReplaceAll End With .ExportAsFixedFormat OutputFileName:="C:\Users\" & Environ("UserName") & "\Documents\Test.pdf", _ ExportFormat:=wdExportFormatPDF, OptimizeFor:=wdExportOptimizeForPrint End With End Sub As for the run-time error, that suggests you or another user already had open the document the code was trying to open. I trust you weren't trying to open the one you were running the macro from (i.e. don't save it to the folder you're trying to process).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
tchase01 | Word VBA | 3 | 03-01-2012 04:03 PM |
![]() |
Yamaha Rider | Word VBA | 2 | 02-07-2012 05:33 PM |
![]() |
Nano07 | Word VBA | 2 | 11-02-2011 05:14 AM |
![]() |
Catalin.B | Excel Programming | 2 | 09-08-2011 11:37 PM |
![]() |
markg2 | Word | 3 | 12-26-2010 04:27 PM |