Public Sub RefreshCustomQuickParts() Dim objRow As Word.Row Dim objCell As Word.Cell Dim strEntryName As String, strCategoryName As String, objEntryRange As Word.Range Dim strMsg As String Dim objNode As Word.XMLNode Dim objContentType As WdBuildingBlockTypes Dim objWordRange As Word.Range Dim i As Integer
With Application
'Check for an active Document:
If .Documents.count = 0 Then
strMsg = "Please open a Word Document."
Call VBA.MsgBox(strMsg, vbInformation + vbOKOnly, .Name)
Exit Sub
End If
'Verify the document with the data:
If .ActiveDocument.Name <> "Custom Quick Parts.docx" Then
strMsg = "Please open or activate Word Document ""Custom Quick Parts.docx."""
Call VBA.MsgBox(strMsg, vbInformation + vbOKOnly, .Name)
Exit Sub
End If
.System.Cursor = wdCursorWait
strCategoryName = "Songhay Custom Quick Parts"
For Each objRow In .ActiveDocument.Tables(1).Rows
For Each objCell In objRow.Cells
With objCell
Set objNode = .Range.XMLNodes(1)
If .ColumnIndex = 1 Then
strEntryName = objNode.Text
ElseIf .ColumnIndex = 2 Then
Set objEntryRange = objNode.Range
End If
End With
Next
Call .NormalTemplate.BuildingBlockEntries.Add(strEntryName, wdTypeCustomQuickParts, strCategoryName, objEntryRange)
Next
.System.Cursor = wdCursorNormal
Call VBA.MsgBox("Custom Quick Parts refreshed.", vbInformation + vbOKOnly, .Name)
End With
End Sub
Public Sub RefreshCustomQuickPartsClick(ByVal control As IRibbonControl) Call RefreshCustomQuickParts End Sub