— by John Bealle
Fellow indexers - I have just completed a Word embedded index using WordEmbed with Sky. James Lamb was very helpful to me, and I would like to share some of the things I learned. Much of this is in the manual and may be common knowledge among seasoned pros. But I was caught off guard by the way embedding works. - John
CODING (things to do during the indexing phase):
DOCUMENT PREP (things to do before embedding):
EMBEDDING:
EDITING (if you need to edit the embedded index):
I have developed several data-entry subroutines using Sky's SICI programming interface. These are extremely useful, mainly in filling in the Page field automatically. They run via Microsoft Word VBA within the indexed document, which happens also to be where WordEmbed runs also. So they are able to interact with both WordEmbed and Sky.
As a brief example, let's say you encounter the passage, "In his analysis, Jones follows the structural approach of Mary Douglas." If you wanted to index the name "Mary Douglas" you might select the name and then create the index tag using that text span. Then you'd paste the WordEmbed tag into the page field and type the name in Main. The SICI subroutine will create a new Sky record, fill in the Page field automatically, invert the phrase "Mary Douglas" to "Douglas, Mary", and fill it in the Main field—all without ever leaving the document.
To set up the macros in Microsoft Word, use the following steps:
Option Compare Text
'Sub NewRecBlankMain()
'F1=LOCATOR ONLY
'Adds a new record with Main=empty, Page=clipboard
'Key Binding: Sft-Ctl-Alt-F1
'-
'Sub NewRec()
'F2=MAIN
'Adds a new record with Main=selected text, Page=clipboard
'Key Binding: Sft-Ctl-Alt-F2
'-
'Sub NewRecInvert()
'F3=INVERTED
'Adds a new record with Main=inverted name from selected text, Page=clipboard
'Key Binding: Sft-Ctl-Alt-F3
'-
'Sub NewRecWithSub()
'F4=INPUT SUB
'Adds a new record with Main=selected text, Sub=Input Box text, Page=clipboard
'Key Binding: Sft-Ctl-Alt-F4
'-
'Sub NewRecItalics()
'F6=MAIN ITALICS
'Adds a new record with Main=selected text in italics, Page=clipboard
'Key Binding: Sft-Ctl-Alt-F6
'-
Sub AssignMacroKeys()
CustomizationContext = NormalTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyShift, wdKeyControl, wdKeyF1), _
KeyCategory:=wdKeyCategoryCommand, Command:="NewRecBlankMain"
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyShift, wdKeyControl, wdKeyF2), _
KeyCategory:=wdKeyCategoryCommand, Command:="NewRec"
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyShift, wdKeyControl, wdKeyF3), _
KeyCategory:=wdKeyCategoryCommand, Command:="NewRecInvert"
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyShift, wdKeyControl, wdKeyF4), _
KeyCategory:=wdKeyCategoryCommand, Command:="NewRecWithSub"
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyShift, wdKeyControl, wdKeyF6), _
KeyCategory:=wdKeyCategoryCommand, Command:="NewRecItalics"
MsgBox ("Sky Key Bindings Assigned")
End Sub
'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Sub SICI_Template()
'this is a template for Sky SICI VB/VBA programs
Dim CI As SICI10.Interface
Dim ST As New SICI10.StyledText 'only needed for styled text functiosn
On Error Resume Next
Set CI = New SICI10.Interface
If Not CI Is Nothing Then
With CI
If CI.RequestConnection Then
'YOUR PROGRAM GOES HERE
Call CI.CloseConnection
Else
MsgBox "Could not create SICI Interface object."
End If
End With
End If
End Sub
'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Sub NewRecBlankMain()
'F1=LOCATOR ONLY
'Adds a new record with Main=empty, Page=clipboard
'Key Binding: Sft-Ctl-Alt-F1
Dim ClipHold As New DataObject
Dim CI As SICI10.Interface
Dim ST As New SICI10.StyledText 'only needed for styled text functiosn
On Error Resume Next
Set CI = New SICI10.Interface
If Not CI Is Nothing Then
With CI
If CI.RequestConnection Then
Set ClipHold = New DataObject
ClipHold.GetFromClipboard
errx = CI.AddRow(" ", ClipHold.GetText)
errx = CI.FirstCell
errx = CI.LastRow
Call CI.CloseConnection
AppActivate "Sky"
Else
MsgBox "Could not create SICI Interface object."
End If
End With
End If
End Sub
'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Sub NewRec()
'Adds a new record with Main=selected text, Page=clipboard
'Key Binding: Sft-Ctl-Alt-F2
Dim ClipHold As New DataObject
Dim CI As SICI10.Interface
Dim ST As New SICI10.StyledText 'only needed for styled text functiosn
On Error Resume Next
Set CI = New SICI10.Interface
If Not CI Is Nothing Then
With CI
If CI.RequestConnection Then
Set ClipHold = New DataObject
ClipHold.GetFromClipboard
errx = CI.AddRow(Selection.Text, ClipHold.GetText)
Call CI.CloseConnection
Else
MsgBox "Could not create SICI Interface object."
End If
End With
End If
End Sub
'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Sub NewRecInvert()
'Adds a new record with Main=inverted name from selected text, Page=clipboard
'Key Binding: Sft-Ctl-Alt-F3
Dim ClipHold As New DataObject
Dim CI As SICI10.Interface
Dim ST As New SICI10.StyledText 'only needed for styled text functiosn
Dim celltext As String
On Error Resume Next
Set CI = New SICI10.Interface
If Not CI Is Nothing Then
With CI
If CI.RequestConnection Then
celltext = Selection.Text
X = GetSetting("SkyNameInverter", "Forms", "Prefixes", "le|la|del|van|de")
prefixarr = Split(X, "|")
X = GetSetting("SkyNameInverter", "Forms", "Suffixes", "Jr.|Sr.|III")
suffixarr = Split(X, "|")
'remove and save suffix
regex.Pattern = "^(.+), (.*?)$"
suffixtext = regex.Replace(ST.PlainStr(celltext), "$2")
For i = 0 To UBound(suffixarr)
If suffixtext = suffixarr(i) Then
suffixtextsave = ST.RightStr(celltext, ST.LenStr(suffixtext))
celltext = ST.LeftStr(celltext, ST.LenStr(celltext) - ST.LenStr(suffixtext))
celltext = ST.RTrimStr(celltext)
ST.SKYText = celltext
Call ST.RemoveTrailingPunctuation(",")
celltext = ST.SKYText
Exit For
Else
If i = UBound(suffixarr) Then suffixtext = ""
End If
Next
'bind prefix
For i = 0 To UBound(prefixarr)
If ST.InString(celltext, prefixarr(i) & " ") = 1 Then celltext = ST.InsertStr(celltext, ST.InString(celltext, prefixarr(i) & " ") + Len(prefixarr(i)), "|")
If ST.InString(celltext, " " & prefixarr(i) & " ") > 0 Then celltext = ST.InsertStr(celltext, ST.InString(celltext, " " & prefixarr(i) & " ") + Len(prefixarr(i)), "|")
If ST.InString(celltext, "|" & prefixarr(i) & " ") > 0 Then celltext = ST.InsertStr(celltext, ST.InString(celltext, "|" & prefixarr(i) & " ") + Len(prefixarr(i)), "|")
Next 'now any prefix words are bound to what follows, e.g., "Manuel de|la|Rosa"
regex.Global = True
regex.Pattern = "\s?\|\s?"
celltext = regex.Replace(celltext, "|")
regex.Global = False
'no commas (invert)
If InStr(1, celltext, ",") = 0 Then
CellTextArr = ST.SplitStr(celltext, " ")
celltext = CellTextArr(UBound(CellTextArr))
celltext = ST.InsertStr(celltext, 1000, ",")
For i = 0 To UBound(CellTextArr) - 1
celltext = ST.InsertStr(celltext, 1000, " ")
celltext = ST.InsertStr(celltext & CellTextArr(i), ST.LenStr(celltext), "")
Next
'comma (uninvert or shift)
Else
CellTextArr = ST.SplitStr(celltext, " ")
celltext = CellTextArr(UBound(CellTextArr))
For i = 0 To UBound(CellTextArr) - 1
celltext = ST.InsertStr(celltext, 1000, " ")
celltext = ST.InsertStr(celltext & CellTextArr(i), ST.LenStr(celltext), "")
Next
ST.SKYText = celltext 'remove trailing comma
Call ST.RemoveTrailingPunctuation(",")
celltext = ST.SKYText
regex.Pattern = "^([A-Z]\.) (.+,.+)$" 'now might have "M. Smith, John"
If regex.test(ST.PlainStr(celltext)) Then
Do 'now might have "M. Smith, John"
CellTextArr = ST.SplitStr(celltext, " ")
celltext = CellTextArr(UBound(CellTextArr))
For i = 0 To UBound(CellTextArr) - 1
celltext = ST.InsertStr(celltext, 1000, " ")
celltext = ST.InsertStr(celltext & CellTextArr(i), ST.LenStr(celltext), " ")
Next
ST.SKYText = celltext 'remove trailing comma
Call ST.RemoveTrailingPunctuation(",")
celltext = ST.SKYText
Loop While regex.test(ST.PlainStr(celltext)) 'test again, might be "R. L. P. Stein"
End If
End If
'clean up from prefixes and suffixes
If suffixtextsave <> "" Then celltext = ST.InsertStr(ST.InsertStr(celltext, 1000, ", ") & suffixtextsave, 1000, "") 'reattach suffix
regex.Pattern = "\|" 'unbind prefix
regex.Global = True
celltext = regex.Replace(celltext, " ")
regex.Global = False
'write cell all done
Set ClipHold = New DataObject
ClipHold.GetFromClipboard
errx = CI.AddRow(celltext, ClipHold.GetText)
Call CI.CloseConnection
Else
MsgBox "Could not create SICI Interface object."
End If
End With
End If
End Sub
'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Sub NewRecWithSub()
'Adds a new record with Main=selected text, Sub=Input Box text, Page=clipboard
'Key Binding: Sft-Ctl-Alt-F4
Dim ClipHold As New DataObject
Dim CI As SICI10.Interface
Dim EntryText As String
On Error Resume Next
Set CI = New SICI10.Interface
If Not CI Is Nothing Then
With CI
If CI.RequestConnection Then
X = InputBox("Enter subheading text:")
EntryText = Selection.Text & vbTab & X
Set ClipHold = New DataObject
ClipHold.GetFromClipboard
errx = CI.AddRow(EntryText, ClipHold.GetText)
Call CI.CloseConnection
Else
MsgBox "Could not create SICI Interface object."
End If
End With
End If
End Sub
'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Sub NewRecItalics()
'Adds a new record with Main=selected text, Page=clipboard
'Key Binding: Sft-Ctl-Alt-F6
Dim ClipHold As New DataObject
Dim SelHold As New DataObject
Dim CI As SICI10.Interface
Dim ST As New SICI10.StyledText 'only needed for styled text functiosn
On Error Resume Next
Set CI = New SICI10.Interface
If Not CI Is Nothing Then
With CI
If CI.RequestConnection Then
'YOUR PROGRAM GOES HERE
Set ClipHold = New DataObject
Set SelHold = New DataObject
ClipHold.GetFromClipboard
SelHold.SetText ("/i1" & Selection.Text & "/i0")
errx = CI.AddRow(SelHold.GetText, ClipHold.GetText)
Call CI.CloseConnection
Else
MsgBox "Could not create SICI Interface object."
End If
End With
End If
End Sub
'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Sub WordEmbedConvert()
'Prepares Sky index for WordEmbed
'Curly Brackets around commas, semicolons, colons
'Curly quotes converted to straight
'Quotes escaped and bracketed
Dim CI As SICI10.Interface
Dim ST As New SICI10.StyledText 'only needed for styled text functiosn
On Error Resume Next
Set CI = New SICI10.Interface
If Not CI Is Nothing Then
With CI
If CI.RequestConnection Then
'YOUR PROGRAM GOES HERE
Dim i As Integer, j As Integer
xerr = CI.LoadIndexRows()
For i = 1 To CI.IndexRows.Count
For j = 0 To 2
xrec = CI.IndexRows(i).Heading(j)
xrecnew = ""
If xrec <> "" Then
For k = 1 To Len(xrec)
xchar = Mid(xrec, k, 1)
Select Case xchar
Case Chr(147)
xrecnew = xrecnew & "{\\""}"
Case Chr(148)
xrecnew = xrecnew & "{\\""}"
Case """"
xrecnew = xrecnew & "{\\""}"
Case ","
xrecnew = xrecnew & "{,}"
Case ":"
xrecnew = xrecnew & "{:}"
Case ";"
xrecnew = xrecnew & "{;}"
Case Else
xrecnew = xrecnew & xchar
End Select
Next k
CI.IndexRows(i).Heading(j) = xrecnew
End If
Next j
Next i
CI.CommitRowChanges ("WordEmbed Setup")
'####################
Call CI.CloseConnection
Else
MsgBox "Could not create SICI Interface object."
End If
End With
End If
End Sub
'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =