Been working on automating the editing of word docx that needs cleanup prior to conversion to pdf. I've got most of the logic, a bit convoluted due to multiple checkboxes, dates and wording that in combination determines what should be displayed. Been able to pull data off the word file and evaluate it. If the logic encounters an issue, it prompts user with an Inputbox to provide corrected values. I noticed that when the data gets replaced in word, it becomes bold if the preceding text was bold even though the actual text being replaced was not bold to begin with. In the screenshot, this is how the data should look. However, after running the access vba code, all the text becomes bold. Also, I noticed that sometimes there are extra spaces or tabs after the text, what is best way to clean that up without removing the final tab as it seems that word uses a final tab to indicate the end of the cell in a word table cell (or that's how it appears to me).
As an example in the code below, it checks the date, if original entry was "TDB", "ASAP", etc, it gets flagged and prompts user to enter a date, the default being today's date.
As an example in the code below, it checks the date, if original entry was "TDB", "ASAP", etc, it gets flagged and prompts user to enter a date, the default being today's date.
Code:
If Not IsDate(stDateSubmitted) Then
'Get new date and replace it in the cell of the word doc
'20190221
stDateSubmitted_New = InputBox(stDateSubmitted & " is not a valid Submit date. Please adjust accordingly.", "Date Issue", Format(Date, "mm/dd/yy"))
WordDoc.tables(1).cell(6, 2).Range.Text = Replace(WordDoc.tables(1).cell(6, 2).Range.Text, stDateSubmitted, stDateSubmitted_New)
stDateSubmitted = stDateSubmitted_New
End If