Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #12  
Old 12-05-2013, 08:28 AM
macropod's Avatar
macropod macropod is offline Loop Macro to Edit Date Windows 7 32bit Loop Macro to Edit Date Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
and produced the attached pdf. The date is wrong, but that's because my regional settings aren't configured for US dates. As you can see, there's no issue with the borders.

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).
Attached Files
File Type: pdf Test.pdf (113.3 KB, 11 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop Macro to Edit Date Macro for tomorrow's Date tchase01 Word VBA 3 03-01-2012 04:03 PM
Loop Macro to Edit Date Macro to loop in Word Yamaha Rider Word VBA 2 02-07-2012 05:33 PM
Loop Macro to Edit Date WORD Macro - import picture - resize - position - page break - loop Nano07 Word VBA 2 11-02-2011 05:14 AM
Loop Macro to Edit Date Macro to loop in subfolders, change links, export xml data Catalin.B Excel Programming 2 09-08-2011 11:37 PM
Loop Macro to Edit Date 'Last edit date' markg2 Word 3 12-26-2010 04:27 PM

Other Forums: Access Forums

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