Private Sub UserForm_Initialize() Dim n As Integer n = ActiveDocument.Bookmarks.Count Dim bmkArray() ReDim bmkArray(1 To n) For i = 1 To n nameSplit = Split(ActiveDocument.Bookmarks(i).Name, "_") bmkArray(i) = nameSplit(1) & vbTab & vbTab & nameSplit(0) Next x = LBound(bmkArray) y = UBound(bmkArray) For i = x To y - 1 For j = i + 1 To y If bmkArray(i) > bmkArray(j) Then temp = bmkArray(i) bmkArray(i) = bmkArray(j) bmkArray(j) = temp End If Next j Next i listPts.List = bmkArray End Sub Private Sub cmdSelect_Click() usrSel = Split(Me.listPts.Value, vbTab & vbTab) usrSelection = usrSel(1) & "_" & usrSel(0) Me.Hide tblDict (usrSelection) Set ufMod = New ufModPatient ufMod.Show vbModeless End Sub Sub tblDict(usrSel As String) modBmk = usrSel Set oTable = ActiveDocument.Bookmarks(usrSel).Range.Tables(1) Set dict = CreateObject("Scripting.Dictionary") dict.Add "room", Split(oTable.Cell(1, 1).Range.Text, vbCr)(0) nameDOB = Split(oTable.Cell(1, 2).Range.Text, vbCr)(0) yo = InStr(nameDOB, "yo") 'Last, First nameBoth = Left(nameDOB, yo - 1) dict.Add "last", Trim(Split(nameBoth, ",")(0)) fNameAGE = Trim(Split(nameBoth, ",")(1)) fNameArray = Split(fNameAGE) If UBound(fNameArray) >= 2 Then FName = fNameArray(0) & " " & fNameArray(1) Else FName = fNameArray(0) End If dict.Add "first", FName 'Gender dict.Add "gender", Mid(nameDOB, yo + 3, 1) 'DOB dob = InStr(nameDOB, "DOB") + 5 mrn = InStr(nameDOB, "MRN") - 3 dict.Add "dob", Mid(nameDOB, dob, mrn - dob) 'MRN dict.Add "mrn", Mid(nameDOB, mrn + 8, 6) dict.Add "admit", Split(oTable.Cell(1, 3).Range.Text, " ")(1) dict.Add "resident", Split(oTable.Cell(2, 2).Range.Text, vbCr)(0) dict.Add "code", Split(oTable.Cell(2, 3).Range.Text, vbCr)(0) txtMeds = Replace(Split(oTable.Cell(3, 1).Range.Text, Chr(7))(0), "Rx: ", "") If Right$(txtMeds, 1) = Chr(13) Then txtMeds = Left$(txtMeds, Len(txtMeds) - 1) dict.Add "meds", txtMeds txtHPI = Split(oTable.Cell(3, 2).Range.Text, Chr(7))(0) If Right$(txtHPI, 1) = Chr(13) Then txtHPI = Left$(txtHPI, Len(txtHPI) - 1) dict.Add "hpi", txtHPI txtFU = Replace(Split(oTable.Cell(3, 3).Range.Text, Chr(7))(0), "F/U: ", "") If Right$(txtFU, 1) = Chr(13) Then txtFU = Left$(txtFU, Len(txtFU) - 1) dict.Add "fu", Replace(txtFU, ChrW(&H2610) & " ", "") txtAllergies = Replace(Split(oTable.Cell(4, 1).Range.Text, Chr(7))(0), "Allergies: ", "") If Right$(txtAllergies, 1) = Chr(13) Then txtAllergies = Left$(txtAllergies, Len(txtAllergies) - 1) dict.Add "allergies", txtAllergies dict.Add "ddx", Replace(Split(oTable.Cell(4, 2).Range.Text, vbCr)(0), "DDx: ", "") txtPain = Replace(Split(oTable.Cell(4, 3).Range.Text, Chr(7))(0), "Pain: ", "") If Right$(txtPain, 1) = Chr(13) Then txtPain = Left$(txtPain, Len(txtPain) - 1) dict.Add "pain", txtPain txtPPx = Replace(Split(oTable.Cell(5, 1).Range.Text, Chr(7))(0), "PPx: ", "") If Right$(txtPPx, 1) = Chr(13) Then txtPPx = Left$(txtPPx, Len(txtPPx) - 1) dict.Add "ppx", txtPPx dict.Add "labs", Replace(Split(oTable.Cell(5, 2).Range.Text, vbCr)(0), "- ", "") dict.Add "imaging", Replace(Split(oTable.Cell(6, 2).Range.Text, vbCr)(0), "- ", "") dict.Add "procedures", Replace(Split(oTable.Cell(7, 2).Range.Text, vbCr)(0), "- ", "") chkmks = UBound(Split(oTable.Cell(5, 3).Range.Text, ChrW(&H2611))) If chkmks = 2 Then dict.Add "anticoag", True dict.Add "insulin", True ElseIf chkmks = 1 Then chk = Replace(Split(oTable.Cell(5, 3).Range.Text, vbCr)(0), ChrW(&H2611) & " ", "") If chk = "Anticoagulated" Then dict.Add "anticoag", True dict.Add "insulin", False Else dict.Add "anticoag", False dict.Add "insulin", True End If Else dict.Add "anticoag", False dict.Add "insulin", False End If dict.Add "dispo", Replace(Split(oTable.Cell(oTable.Rows.Count, 1).Range.Text, vbCr)(0), "Dispo: ", "") 'dict.Add "timestamp", Split(oTable.Cell(oTable.Rows.Count, 2).Range.Text, vbCr)(0) 'dict.Add "username", " " raw = Split(oTable.Cell(oTable.Rows.Count, 2).Range.Text, vbCr)(0) dt = Mid(raw, 1, InStr(raw, " (") - 1) ini = Mid(raw, InStr(raw, " (") + 2, 3) dict.Add "timestamp", dt dict.Add "username", ini End Sub