Apr 27 2022 11:13 AM
The following code has run well for over a year and recently stopped working. It opens the Word doc, does a find and replace, saves the modified doc as a PDF then closed the original doc without changing it. All this works except the find and replace - for some reason the doc cannot be edited. Anyone have any ideas? There are no errors during the run. Thx
Set wrdDoc = wrdApp.Documents.Open("c:\JIBE\testing.docx")
With WordApp
With wrdDoc.Content.Find
.ClearFormatting
.Text = "**VesselName**"
.Replacement.Text = cls!VesselName
.Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End With
With wrdDoc.Content.Find
.ClearFormatting
.Text = "**CustomsDecal**"
.Replacement.Text = cls!CustomsDecal
.Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End With
With wrdDoc.Content.Find
.ClearFormatting
.Text = "**DocNumber**"
.Replacement.Text = cls!DocNumber
.Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End With
End With
wrdDoc.SaveAs2 "c:\PDFtemp\JIBETemp - Customs.PDF", 17
wrdDoc.Close SaveChanges:=False
ShellAndWait "c:\PDFtemp\JIBETemp - Customs.PDF"
Apr 27 2022 05:38 PM
Apr 28 2022 07:24 AM