Hello Everyone and Happy Monday,
I am trying to export a form and it is basic now, but in the end it will be populating a table with data from Access. I am trying to highlight one sentence when it exports to Word. I cannot figure it out after many Google searches. This is my first time trying to use highlights.
I would like the following sentence to be highlighted yellow - "Please provide the information requested below by 9/14/16."
I am trying to export a form and it is basic now, but in the end it will be populating a table with data from Access. I am trying to highlight one sentence when it exports to Word. I cannot figure it out after many Google searches. This is my first time trying to use highlights.
I would like the following sentence to be highlighted yellow - "Please provide the information requested below by 9/14/16."
Code:
Private Sub cmdgenerate_Click()
Dim docWord As Word.Document
Dim rngCurrent As Word.Range
Dim tableWord As Word.Table
Const wdWord9TableBehavior = 1
Const wdAutoFitFixed = 2
Set appword = New Word.Application
appword.Visible = True
Set docWord = appword.Documents.Add()
Set rngCurrent = docWord.Content
With rngCurrent
.InsertAfter "Please provide the information requested below by 9/14/16."
.InsertAfter vbCrLf
.InsertAfter Date
.InsertParagraphAfter
.Collapse Direction:=wdCollapseEnd
End With
Set tableWord = docWord.Tables.Add(rngCurrent, 20, 2, wdWord9TableBehavior, wdAutoFitFixed)
With tableWord
.Cell(1, 1).Range.Text = "Resource"
.Cell(1, 2).Range.Text = "Task"
End With
MsgBox "Completed", vbOKOnly
End Sub