BuffaloGuy
New Member
- Joined
- Dec 5, 2017
- Messages
- 28
I set up some code in visual basic to replace text in a Word Template with text from an excel cell. one of the cells is the date the report is written. I enter info as 2/23/18 and i formatted the cells to change the date to "Long Form" (i.e. February 23,2018). I want to change the format of the dates that get replaced to "Long Form". Thoughts?
Private Sub Build_Click()
Template = "C:\Users\Desktop\Report.docx"
Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open(Template, ReadOnly:=True)
wrdApp.Visible = True
wrdApp.Selection.Find.ClearFormatting
wrdApp.Selection.Find.Replacement.ClearFormatting
'Report Date
With wrdApp.Selection.Find
.Text = "Report_Date"
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
wrdApp.Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Private Sub Build_Click()
Template = "C:\Users\Desktop\Report.docx"
Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open(Template, ReadOnly:=True)
wrdApp.Visible = True
wrdApp.Selection.Find.ClearFormatting
wrdApp.Selection.Find.Replacement.ClearFormatting
'Report Date
With wrdApp.Selection.Find
.Text = "Report_Date"
.Replacement.Text = Range("B1")
.Forward = True.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
wrdApp.Selection.Find.Execute Replace:=wdReplaceAll
End Sub