Dim strParagraphs(100) As String
Dim intFrontPointer As Long
Dim intBackPointer As Long
Dim intTotalParagraphs As Long
'
' In this example, paragraphs are delimited by a "double carriage-return"
'
' First, is there more than one paragraph?
'
intBackPointer = InStr(1, Me.YourMemoField, vbCrLf & vbCrLf)
If intBackPointer = 0 Then
' Only 1 paragraph
strParagraphs(1) = Me.YourMemoField
intTotalParagraphs = 1
Else
' Count the paragraph, store it in an array, increment total count, then move
' the BackPointer to the FrontPointer, then check for any more paragraphs.
While intBackPointer > 0
intTotalParagraphs = intTotalParagraphs + 1
strParagraphs(intTotalParagraphs) = Mid(Me.YourMemoField, intFrontPointer, intBackPointer - intFrontPointer)
intTotalParagraphs = intTotalParagraphs + 1
intFrontPointer = intBackPointer + 2
intBackPointer = InStr(1, Me.YourMemoField, vbCrLf & vbCrLf)
Wend
' Get the "last paragraph"
intTotalParagraphs = intTotalParagraphs + 1
strParagraphs(intTotalParagraphs) = Mid(Me.YourMemoField, intFrontPointer)
Private Sub AccessClin_Click()
Dim objWord As Word.Application
Dim MyString, MyArray, ArraySize As Integer
Dim Par As Integer
Set objWord = CreateObject("Word.Application")
With objWord
.Visible = True
.Documents.Open ("AnnualCompetencyformclin.doc")
.ActiveDocument.Bookmarks("Job_Title").Select
.Selection.Text = (CStr(Forms!HumanResourcesForm3!JobTitle))
.ActiveDocument.Bookmarks("Department").Select
.Selection.Text = (CStr(Forms!HumanResourcesForm3!Department))
.ActiveDocument.Bookmarks("Assessment1").Select
If IsNull(Forms!HumanResourcesForm3!Assessment1) Then
.Selection.Text = ""
Else
MyString = (CStr(Forms!HumanResourcesForm3!Assessment1))
MyArray = Split(MyString, vbCrLf, -1, 1)
ArraySize = UBound(MyArray)
For Par = 1 To ArraySize
Select Case Par
Case 1
.SelectionText = MyArray(1)
Case 2
.ActiveDocument.Bookmarks("2nd Para").Select
.SelectionText = MyArray(2)
Case 3
.ActiveDocument.Bookmarks("3rd Para").Select
.SelectionText = MyArray(3)
Case 4
.ActiveDocument.Bookmarks("4th Para").Select
.SelectionText = MyArray(4)
Case Else
MsgBox("I didn't put a bookmark for more than 4 paragraphs.")
Stop
End Select
Next Par
End If
End With