dean.rogers
New Member
- Joined
- Apr 6, 2012
- Messages
- 31
Hey all,
What I would like to do is by use if excel VBA, I would like to have excel prompt word to enter in "todays date" where ever I have placed the respective variable. For instance, where ever I have [todays_date] located in my WordTemplate, then todays date will be inserted when I run my macro from excel. Below is the current code I have in place to map data from excel to word by finding a variable in word and replacing with a determined by a range in excel.
I'm sure there is someway to do it but havent been able to find it anywhere.
Thank you for your help!!!
What I would like to do is by use if excel VBA, I would like to have excel prompt word to enter in "todays date" where ever I have placed the respective variable. For instance, where ever I have [todays_date] located in my WordTemplate, then todays date will be inserted when I run my macro from excel. Below is the current code I have in place to map data from excel to word by finding a variable in word and replacing with a determined by a range in excel.
Code:
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open("C:\Templates\WordTemplate.docx")
On Error Resume Next
With wrdDocSelection.Find
.Text = "[excel_data]"
.MatchWholeWord = False
.Replacement.Text = ActiveWorkbook.Sheets("sheet1").Range("D3")
.Execute , , , , , , , , , , wdReplaceAll
wrdApp.ActiveDocument.Save
I'm sure there is someway to do it but havent been able to find it anywhere.
Thank you for your help!!!