Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I figured this out myself. It seemed easiest to first create an Excel spreadsheet from the query and work from there so that's what I did. Next I created the following VBA macro:</p> <pre><code>Sub BuildAlarmDict() Dim exApp As New Excel.Application Dim exWb As Excel.Workbook Dim exWs As Excel.Worksheet Dim row As Integer Dim tbl As Word.Table Dim para As Paragraph Dim myRng As Range Set exWb = exApp.Workbooks.Open("C:\AlarmDictData.xls") Set exWs = exWb.Sheets(1) For row = exWs.UsedRange.Rows.Count To 1 Step -1 Set myRng = ActiveDocument.Range(Start:=Selection.Range.End, End:=Selection.Range.End) With myRng .Collapse Direction:=wdCollapseEnd .InsertParagraphAfter .Collapse Direction:=wdCollapseEnd End With Set tbl = ActiveDocument.Tables.Add(Range:=myRng, NumRows:=6, NumColumns:=2) With tbl .AllowPageBreaks = False .Columns(1).Width = 122 .Columns(2).Width = 351 With .Rows(1) .Cells.Merge .Shading.BackgroundPatternColorIndex = 16 With .Range .Bold = True .ParagraphFormat.Alignment = wdAlignParagraphCenter .Font.Size = 12 End With End With With .Borders .InsideLineStyle = wdLineStyleSingle .OutsideLineStyle = wdLineStyleSingle End With .Cell(1, 1).Range.Text = exWs.Cells(row, 1) &amp; " : " &amp; exWs.Cells(row, 2) .Cell(2, 1).Range.Text = "Alarm Code" .Cell(2, 2).Range.Text = exWs.Cells(row, 1) .Cell(3, 1).Range.Text = "Specific Problem" .Cell(3, 2).Range.Text = exWs.Cells(row, 2) .Cell(4, 1).Range.Text = "Perceived Severity" .Cell(4, 2).Range.Text = exWs.Cells(row, 3) .Cell(5, 1).Range.Text = "Probable Cause" .Cell(5, 2).Range.Text = exWs.Cells(row, 4) .Cell(6, 1).Range.Text = "Additional Text" .Cell(6, 2).Range.Text = exWs.Cells(row, 5) End With Next exWb.Close Set exApp = Nothing End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload