JustJoe21

Untitled

Dec 28th, 2024
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.73 KB | None | 0 0
  1. 'Main userform
  2. Private Sub UserForm_Initialize()
  3. InitializeForm
  4. ' Sets object defaults
  5. cb_Extension = False
  6. txt_Extension.Visible = False
  7. label_ExtendTime.Visible = False
  8. CompassFrame.Visible = False
  9. FireExtFrame.Visible = False
  10. FirstAidFrame.Visible = False
  11. WBFrame.Visible = False
  12. DualsFrame.Visible = False
  13. opt_Maint.Value = True
  14.  
  15. ' Hide box_Duals content control by default
  16. Dim boxDuals As ContentControl
  17. Set boxDuals = ActiveDocument.SelectContentControlsByTitle("box_Duals").item(1)
  18. If Not boxDuals Is Nothing Then
  19. boxDuals.Range.Font.Hidden = True
  20. End If
  21.  
  22. End Sub
  23.  
  24. Private Sub InitializeForm()
  25. ' Arrays for combo box values
  26. Dim inspectionTypes As Variant
  27. inspectionTypes = Array("75 Hour inspection", "150 Hour inspection", "300 Hour inspection", _
  28. "1500 Hour inspection", "6000 Hour inspection", "100 Hour inspection", _
  29. "500 Hour inspection", "1000 Hour inspection")
  30.  
  31. Dim dualNames As Variant
  32. dualNames = Array("Dave J", "Dave M", "Steve", "Peter", "Pierre", "Marc", "Ken")
  33.  
  34. ' Populate BottomAddsList
  35. Dim bottomAddsItems As Variant
  36. bottomAddsItems = Array("Engine leak check required after first flight", _
  37. "Aircraft released conditional to satisfactory 1500hr inspection / engine break in test flight ", _
  38. "Aircraft released conditional to satisfactory test flight due to fuel system adjustments carried out", _
  39. "Propeller torque check required after first flight and after first 25hrs to not exceed X hrs TTAF", _
  40. "Initial 5hr alternator belt tension check required to not exceed Y hrs ", _
  41. "Initial 25hr engine operation inspection required to not exceed X hrs TTAF", _
  42. "25 hour propeller retorque due at X hrs TTAF")
  43.  
  44.  
  45. 'Allows multiselect for bottom items
  46. Dim item As Variant
  47. For Each item In bottomAddsItems
  48. Me.BottomAddsList.AddItem item
  49. Next item
  50. Me.BottomAddsList.MultiSelect = fmMultiSelectMulti
  51.  
  52. ' Populate inspection type combo box
  53. For Each item In inspectionTypes
  54. Me.cmb_InspectionType.AddItem item
  55. Next item
  56. Me.cmb_InspectionType.Value = "75 Hour inspection" ' Default value
  57.  
  58. ' Populate duals combo box
  59. For Each item In dualNames
  60. Me.cmb_Duals.AddItem item
  61. Next item
  62.  
  63. ' Populate recurring defect combo box
  64. With Me.cmb_RecurDef
  65. .AddItem "No"
  66. .AddItem "Yes"
  67. .Value = "No" ' Default value
  68. End With
  69. End Sub
  70.  
  71. Public Function BuildWPFull() As String
  72. Dim regPart As String
  73. regPart = Right(txt_Reg.text, 3)
  74. BuildWPFull = UCase(regPart & "-" & txt_WPYear.text & "-" & txt_WPNumber.text)
  75. End Function
  76. 'This function displays shortened names in the Duals drop down menu, and prints the full name W/ license number on the release
  77. Private Function GetFullName(shortName As String) As String
  78. Select Case shortName
  79. Case "Dave J"
  80. GetFullName = "David Jones 450901"
  81. Case "Dave M"
  82. GetFullName = "Dave Melanson 414817"
  83. Case "Steve"
  84. GetFullName = "Stephen Humphrey 811691"
  85. Case "Peter"
  86. GetFullName = "Peter Roberts 451738"
  87. Case "Pierre"
  88. GetFullName = "Pierre Damboise 451004"
  89. Case "Marc"
  90. GetFullName = "Marc Vautour 414479"
  91. Case "Ken"
  92. GetFullName = "Ken Branch 415274"
  93. Case Else
  94. GetFullName = shortName
  95. End Select
  96. End Function
  97. 'This controls visibility of boxes on userform based on maintenance type being selected
  98. Private Sub SetVisibility(ByVal inspectionTypeVisible As Boolean, _
  99. ByVal snagEntryVisible As Boolean, _
  100. ByVal extensionVisible As Boolean)
  101. cmb_InspectionType.Visible = inspectionTypeVisible
  102. label_InspectionType.Visible = inspectionTypeVisible
  103. cb_Extension.Visible = extensionVisible
  104. txt_SnagEntry.Visible = snagEntryVisible
  105. label_SnagEntry.Visible = snagEntryVisible
  106. label_SnagRectification.Visible = snagEntryVisible
  107. txt_SnagRect.Visible = snagEntryVisible
  108. End Sub
  109.  
  110. Private Sub opt_Snag_Click()
  111. SetVisibility False, True, False
  112. UpdateContentBoxesVisibility
  113. End Sub
  114.  
  115. Private Sub opt_Maint_Click()
  116. SetVisibility True, False, True
  117. UpdateContentBoxesVisibility
  118. End Sub
  119.  
  120. Private Sub opt_Both_Click()
  121. SetVisibility True, True, True
  122. UpdateContentBoxesVisibility
  123. End Sub
  124.  
  125. Private Sub UpdateContentBoxesVisibility()
  126. Dim ccSnag As ContentControl
  127. Dim ccMaint As ContentControl
  128.  
  129. Set ccSnag = ActiveDocument.SelectContentControlsByTag("box_Snag")(1)
  130. Set ccMaint = ActiveDocument.SelectContentControlsByTag("box_Maint")(1)
  131.  
  132. If opt_Snag.Value Then
  133. ccSnag.Range.Font.Hidden = False
  134. ccMaint.Range.Font.Hidden = True
  135. ElseIf opt_Maint.Value Then
  136. ccSnag.Range.Font.Hidden = True
  137. ccMaint.Range.Font.Hidden = False
  138. ElseIf opt_Both.Value Then
  139. ccSnag.Range.Font.Hidden = False
  140. ccMaint.Range.Font.Hidden = False
  141. End If
  142. End Sub
  143.  
  144. Private Sub btnSubmit_Click()
  145. Dim doc As Document
  146. Dim WPFull As String
  147. WPFull = BuildWPFull()
  148. Set doc = Application.ActiveDocument
  149.  
  150. Call UpdateContentControls
  151.  
  152. If opt_Snag.Value = True Or opt_Both.Value = True Then
  153. UpdateSnagContent "Snag: " & txt_SnagEntry.Value, "text_SnagTitle"
  154. UpdateSnagContent txt_SnagRect.Value, "text_SnagRectify"
  155. End If
  156.  
  157. UpdateMaintHeader doc, cmb_InspectionType.Value, cb_Extension.Value
  158.  
  159. Dim ExtensionChecked As Boolean
  160. Dim AddWorkChecked As Boolean
  161. Dim inspectionType As String
  162.  
  163. ExtensionChecked = cb_Extension.Value
  164. AddWorkChecked = cb_Addwork.Value
  165. inspectionType = cmb_InspectionType.Value
  166.  
  167. UpdateMaintenanceBody ExtensionChecked, inspectionType, AddWorkChecked
  168.  
  169. If cb_Compass.Value = True Then
  170. UpdateCompassHeadings
  171. End If
  172.  
  173. Call AddBottomEntries(text25.Value, text5.Value, txtCustomEntry.Value)
  174. End Sub
  175.  
  176. Private Sub UpdateContentControls()
  177. Dim cc As ContentControl
  178. Dim WPFull As String
  179. WPFull = BuildWPFull()
  180.  
  181. For Each cc In ActiveDocument.ContentControls
  182. Select Case cc.tag
  183. Case "Text_Reg"
  184. cc.Range.text = UCase(txt_Reg.text)
  185. Case "Text_Date"
  186. cc.Range.text = txt_Date.text
  187. Case "Doc_RecDef"
  188. cc.Range.text = cmb_RecurDef.Value
  189. Case "Text_TTAF"
  190. cc.Range.text = txt_TTAF.text & " Hrs"
  191. Case "Text_WPFull"
  192. cc.Range.text = WPFull
  193. cc.Range.Font.Bold = True
  194. Case "Doc_InspectionType"
  195. cc.Range.text = cmb_InspectionType.Value
  196. End Select
  197. Next cc
  198. End Sub
  199.  
  200. Private Sub cb_Compass_Click()
  201. CompassFrame.Visible = cb_Compass.Value
  202.  
  203. Dim doc As Document
  204. Dim cc As ContentControl
  205. Dim tbl As Table
  206. Dim ccInTable As ContentControl
  207. Dim tblRange As Range
  208.  
  209. Set doc = ActiveDocument
  210.  
  211. For Each cc In doc.ContentControls
  212. If cc.tag = "box_Compass" Then
  213. If cc.Range.Tables.Count > 0 Then
  214. Set tbl = cc.Range.Tables(1)
  215. Set tblRange = tbl.Range
  216. Exit For
  217. End If
  218. End If
  219. Next cc
  220.  
  221. If Not tbl Is Nothing Then
  222. If cb_Compass.Value Then
  223. tblRange.Font.Hidden = False
  224. For Each ccInTable In doc.ContentControls
  225. If ccInTable.Range.Start >= tblRange.Start And ccInTable.Range.End <= tblRange.End Then
  226. ccInTable.Range.Font.Hidden = False
  227. End If
  228. Next ccInTable
  229. Else
  230. tblRange.Font.Hidden = True
  231. For Each ccInTable In doc.ContentControls
  232. If ccInTable.Range.Start >= tblRange.Start And ccInTable.Range.End <= tblRange.End Then
  233. ccInTable.Range.Font.Hidden = True
  234. End If
  235. Next ccInTable
  236. End If
  237. End If
  238. End Sub
  239.  
  240. Private Sub UpdateCompassHeadings()
  241. Dim cc As ContentControl
  242. Dim userFormControl As MSForms.Control
  243. Dim contentControlName As String
  244. Dim userFormTextboxName As String
  245.  
  246. For Each cc In ActiveDocument.ContentControls
  247. Select Case cc.tag
  248. Case "text_North", "text_30", "text_60", "text_East", "text_120", _
  249. "text_150", "text_South", "text_210", "text_240", _
  250. "text_West", "text_300", "text_330"
  251.  
  252. userFormTextboxName = Replace(cc.tag, "text_", "txt")
  253. Set userFormControl = Me.Controls(userFormTextboxName)
  254.  
  255. If Not userFormControl Is Nothing Then
  256. cc.Range.text = UCase(userFormControl.Value)
  257. End If
  258. End Select
  259. Next cc
  260. End Sub
  261.  
  262. Private Sub cb_Extension_Click()
  263. label_ExtendTime.Visible = cb_Extension.Value
  264. txt_Extension.Visible = cb_Extension.Value
  265. End Sub
  266.  
  267. Private Sub cb_FireExt_Click()
  268. FireExtFrame.Visible = cb_FireExt.Value
  269. End Sub
  270.  
  271. Private Sub cb_FirstAidKit_Click()
  272. FirstAidFrame.Visible = cb_FirstAidKit.Value
  273. End Sub
  274.  
  275. Private Sub cb_WB_Click()
  276. WBFrame.Visible = cb_WB.Value
  277. End Sub
  278.  
  279. Private Sub AddBottomEntries(userNumberX As String, userNumberY As String, customEntry As String)
  280. Dim i As Integer
  281. Dim selectedItem As String
  282.  
  283. For i = 0 To BottomAddsList.ListCount - 1
  284. If BottomAddsList.Selected(i) Then
  285. selectedItem = Replace(Replace(BottomAddsList.List(i), "X", userNumberX), "Y", userNumberY)
  286. AddTextToDocument "*** " & Trim(selectedItem) & " ***", True
  287. End If
  288. Next i
  289.  
  290. If customEntry <> "" Then
  291. AddTextToDocument "*** " & Trim(customEntry) & " ***", True
  292. End If
  293. End Sub
  294. 'Adds the notes to the bottom and centeres it
  295. Private Sub AddTextToDocument(text As String, alignCenter As Boolean)
  296. Selection.EndKey Unit:=wdStory
  297. Selection.TypeParagraph
  298. If alignCenter Then
  299. Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
  300. End If
  301. Selection.TypeText text:=text & vbCrLf
  302. End Sub
  303.  
  304. Private Sub cb_Duals_Click()
  305. Dim doc As Document
  306. Set doc = ActiveDocument
  307.  
  308. DualsFrame.Visible = cb_Duals.Value
  309.  
  310. Dim boxDuals As ContentControl
  311. Set boxDuals = doc.SelectContentControlsByTitle("box_Duals").item(1)
  312.  
  313. If Not boxDuals Is Nothing Then
  314. If cb_Duals.Value Then
  315. boxDuals.Range.Font.Hidden = False
  316. Else
  317. boxDuals.Range.Font.Hidden = True
  318. End If
  319. End If
  320. End Sub
  321.  
  322. Private Sub cb_DualTCs_Click()
  323. DualsUserform.Show
  324. End Sub
  325.  
  326. Private Sub cmb_Duals_Change()
  327. Dim fullName As String
  328. Dim cc As ContentControl
  329.  
  330. fullName = GetFullName(cmb_Duals.Value)
  331.  
  332. For Each cc In ActiveDocument.ContentControls
  333. If cc.tag = "text_PerfDual" Then
  334. cc.Range.text = fullName
  335. Exit For
  336. End If
  337. Next cc
  338. End Sub
  339.  
  340.  
  341. 'Duals userform
  342. Option Explicit
  343. Private counter As Integer
  344.  
  345. Private Sub UserForm_Initialize()
  346. counter = 1
  347. End Sub
  348.  
  349. Private Sub cb_AddRow_Click()
  350. counter = counter + 1
  351.  
  352. Dim lastControlBox As MSForms.TextBox
  353. Dim lastTCBox As MSForms.TextBox
  354. Set lastControlBox = Me.Controls("txt_DualControl" & (counter - 1))
  355. Set lastTCBox = Me.Controls("txt_DualTC" & (counter - 1))
  356.  
  357. Dim newControlBox As MSForms.TextBox
  358. Dim newTCBox As MSForms.TextBox
  359.  
  360. Set newControlBox = Me.Controls.Add("Forms.TextBox.1", "txt_DualControl" & counter)
  361. With newControlBox
  362. .Left = lastControlBox.Left
  363. .Top = lastControlBox.Top + lastControlBox.Height + 5
  364. .Width = lastControlBox.Width
  365. .Height = lastControlBox.Height
  366. End With
  367.  
  368. Set newTCBox = Me.Controls.Add("Forms.TextBox.1", "txt_DualTC" & counter)
  369. With newTCBox
  370. .Left = lastTCBox.Left
  371. .Top = lastTCBox.Top + lastTCBox.Height + 5
  372. .Width = lastTCBox.Width
  373. .Height = lastTCBox.Height
  374. End With
  375.  
  376. Dim cc As ContentControl
  377. Dim tbl As Table
  378.  
  379. For Each cc In ActiveDocument.ContentControls
  380. If cc.tag = "box_DualTCs" Then
  381. Set tbl = cc.Range.Tables(1)
  382. tbl.Rows.Add
  383. Exit For
  384. End If
  385. Next cc
  386. End Sub
  387.  
  388. Public Sub TransferDataToTable()
  389. Dim cc As ContentControl
  390. Dim tbl As Table
  391. Dim i As Integer
  392.  
  393. For Each cc In ActiveDocument.ContentControls
  394. If cc.tag = "box_DualTCs" Then
  395. Set tbl = cc.Range.Tables(1)
  396.  
  397. For i = 1 To counter
  398. Dim controlBox As MSForms.TextBox
  399. Dim tcBox As MSForms.TextBox
  400.  
  401. Set controlBox = Me.Controls("txt_DualControl" & i)
  402. Set tcBox = Me.Controls("txt_DualTC" & i)
  403.  
  404. tbl.Rows(i).Cells(1).Range.text = controlBox.text
  405. tbl.Rows(i).Cells(2).Range.text = tcBox.text
  406. Next i
  407.  
  408. Exit For
  409. End If
  410. Next cc
  411. End Sub
  412.  
  413. Private Sub cb_AddData_Click()
  414. TransferDataToTable
  415. Me.Hide
  416. End Sub
  417.  
  418.  
  419. 'Formatting module
  420.  
  421. Public Sub ApplyTextFormatToText(ByRef targetRange As Range, _
  422. ByVal textToFormat As String, _
  423. Optional ByVal FontName As String = "Times New Roman", _
  424. Optional ByVal FontSize As Single = 8, _
  425. Optional ByVal Bold As Boolean = True, _
  426. Optional ByVal Italic As Boolean = False, _
  427. Optional ByVal Underline As Boolean = False, _
  428. Optional ByVal FontColor As Long = wdColorAutomatic, _
  429. Optional ByVal Alignment As WdParagraphAlignment = wdAlignParagraphLeft)
  430. ' Check if targetRange is valid
  431. If targetRange Is Nothing Or targetRange.text = "" Then Exit Sub
  432.  
  433. ' Find and format the text
  434. With targetRange.Find
  435. .text = textToFormat
  436. .MatchCase = False
  437. .MatchWholeWord = False
  438. If .Execute Then
  439. With .Parent
  440. ' Apply font properties
  441. With .Font
  442. .Name = FontName
  443. .Size = FontSize
  444. .Bold = Bold
  445. .Italic = Italic
  446. .Underline = IIf(Underline, wdUnderlineSingle, wdUnderlineNone)
  447. .Color = FontColor
  448. End With
  449. ' Apply paragraph alignment
  450. .ParagraphFormat.Alignment = Alignment
  451. End With
  452. End If
  453. End With
  454. End Sub
  455.  
  456.  
  457. ' Helper function to add section content with proper formatting
  458. Public Sub AddFormattedSection(ByRef content As String, ByVal mainText As String, ByRef subItems() As String, ByVal WPFull As String)
  459. content = content & vbCrLf & mainText & " REF WP " & WPFull
  460. Dim subItem As Variant
  461. For Each subItem In subItems
  462. If subItem <> "" Then
  463. content = content & vbCrLf & subItem
  464. End If
  465. Next subItem
  466. End Sub
  467.  
  468. 'Updatting content module
  469.  
  470. Public Sub UpdateSnagContent(ByVal textToInsert As String, ByVal contentTag As String)
  471. Dim doc As Document
  472. Dim cc As ContentControl
  473.  
  474. ' Get the active document
  475. Set doc = ActiveDocument
  476.  
  477. ' Update content if conditions are met (for SnagRect)
  478. If contentTag = "text_SnagRectify" Then
  479. If Not (ReleaseHub.opt_Snag.Value = True Or ReleaseHub.opt_Both.Value = True) Then
  480. Exit Sub
  481. End If
  482. End If
  483.  
  484. ' Find and update the content control
  485. For Each cc In doc.ContentControls
  486. If cc.tag = contentTag Then
  487. cc.Range.text = textToInsert
  488. Exit For
  489. End If
  490. Next cc
  491. End Sub
  492.  
  493.  
  494.  
  495. Public Sub UpdateMaintHeader(doc As Word.Document, inspectionType As String, isExtension As Boolean)
  496. Dim cc As Word.ContentControl
  497. Dim maintTitleText As String
  498.  
  499. 'Sub is good, only updates header.
  500.  
  501. ' Find the content control by tag
  502. For Each cc In doc.ContentControls
  503. If cc.tag = "text_MaintTitle" Then Exit For
  504. Next cc
  505.  
  506. If cc Is Nothing Then Exit Sub ' Exit silently if not found
  507.  
  508. ' Determine the text to set based on isExtension value
  509. If isExtension Then
  510. maintTitleText = "Maintenance: " & inspectionType & " extension to be carried out"
  511. Else
  512. maintTitleText = "Maintenance: " & inspectionType & " to be carried out"
  513. End If
  514.  
  515. ' Update the content control text
  516. cc.Range.text = maintTitleText
  517. End Sub
  518.  
  519.  
  520. ' Helper function to format each paragraph with proper indentation and styling
  521. Private Sub FormatParagraph(ByVal para As Paragraph, ByVal isMainEntry As Boolean, ByVal isBold As Boolean)
  522. With para.Range
  523. .Font.Size = 8
  524. .Font.Bold = isBold
  525. .ListFormat.ListLevelNumber = IIf(isMainEntry, 1, 2)
  526. End With
  527. End Sub
  528.  
  529. ' Function to handle Fire Extinguisher section
  530. Private Function GetFireExtinguisherContent(ByVal frm As ReleaseHub, ByVal WPFull As String) As String
  531. If Not frm.cb_FireExt.Value Then Exit Function
  532.  
  533. Dim content As String
  534. Dim subItems(2) As String
  535. subItems(0) = "Next annual inspection due " & frm.txt_FireAnnual.Value
  536. subItems(1) = "Next 6 year inspection due " & frm.txt_Fire6Year.Value
  537. subItems(2) = "Next 12 year hydrostatic inspection due " & frm.txt_Fire12Year.Value
  538.  
  539. AddFormattedSection content, "Fire extinguisher annual inspection carried out", subItems, WPFull
  540. GetFireExtinguisherContent = content
  541. End Function
  542.  
  543. ' Function to handle First Aid Kit section
  544. Private Function GetFirstAidKitContent(ByVal frm As ReleaseHub, ByVal WPFull As String) As String
  545. If Not frm.cb_FirstAidKit.Value Then Exit Function
  546.  
  547. Dim content As String
  548. Dim subItems(0) As String
  549. subItems(0) = "Next annual inspection due " & frm.txt_FirstAidAnnual.Value
  550.  
  551. AddFormattedSection content, "First aid kit annual inspection carried out", subItems, WPFull
  552. GetFirstAidKitContent = content
  553. End Function
  554.  
  555. ' Function to handle Weight and Balance section
  556. Private Function GetWeightBalanceContent(ByVal frm As ReleaseHub, ByVal WPFull As String) As String
  557. If Not frm.cb_WB.Value Then Exit Function
  558.  
  559. Dim content As String
  560. Dim subItems(2) As String
  561. subItems(0) = "New aircraft empty weight: " & frm.txt_WBEW.Value & " Lbs"
  562. subItems(1) = "New aircraft C of G arm: " & frm.txt_WBCoG.Value & " inches"
  563. subItems(2) = "New aircraft moment: " & frm.txt_WBMoment.Value
  564.  
  565. AddFormattedSection content, "Weight and balance amendment # " & frm.txt_WBAmend.Value & " now in effect.", subItems, WPFull
  566. GetWeightBalanceContent = content
  567. End Function
  568.  
  569. ' Main procedure
  570. Public Sub UpdateMaintenanceBody(ByVal ExtensionValue As Boolean, ByVal InspectionTypeValue As String, ByVal AddWorkChecked As Boolean)
  571. Dim doc As Document
  572. Set doc = ActiveDocument
  573.  
  574. Dim frm As ReleaseHub
  575. Set frm = ReleaseHub
  576.  
  577. Dim WPFull As String
  578. WPFull = frm.BuildWPFull
  579.  
  580. ' Get the content control
  581. Dim ccRange As Range
  582. Set ccRange = doc.SelectContentControlsByTag("text_MaintBody")(1).Range
  583.  
  584. ' Build the initial content
  585. Dim content As String
  586. If ExtensionValue Then
  587. content = InspectionTypeValue & " and all related tasks in WP " & WPFull & _
  588. " extended 10 hours and now due at " & frm.txt_Extension.Value & " Hrs"
  589. Else
  590. content = InspectionTypeValue & " carried out REF WP " & WPFull
  591. End If
  592.  
  593. ' Add additional work line if checked
  594. If AddWorkChecked Then
  595. content = content & vbCrLf & "Additional work carried out REF WP " & WPFull
  596. End If
  597.  
  598. ' Add specialized sections
  599. content = content & GetFireExtinguisherContent(frm, WPFull)
  600. content = content & GetFirstAidKitContent(frm, WPFull)
  601. content = content & GetWeightBalanceContent(frm, WPFull)
  602.  
  603. ' Add compass swing if checked
  604. If frm.cb_Compass.Value Then
  605. content = content & vbCrLf & "Compass swing carried out REF WP " & WPFull & ". New headings below."
  606. End If
  607.  
  608. ' Set the content
  609. ccRange.text = content
  610.  
  611. ' Format the content
  612. With ccRange
  613. .Font.Size = 8
  614. .ListFormat.RemoveNumbers
  615. .ListFormat.ApplyListTemplateWithLevel _
  616. ListTemplate:=ListGalleries(wdNumberGallery).ListTemplates(1), _
  617. ContinuePreviousList:=False, _
  618. ApplyTo:=wdListApplyToWholeList, _
  619. DefaultListBehavior:=wdWord10ListBehavior
  620.  
  621. ' Format each paragraph
  622. For Each mainPara In .Paragraphs
  623. Dim isMainEntry As Boolean
  624. Dim isBold As Boolean
  625.  
  626. ' Determine formatting based on content
  627. If InStr(mainPara.Range.text, "Weight and balance") > 0 Then
  628. isMainEntry = True
  629. isBold = True
  630. ElseIf InStr(mainPara.Range.text, "New aircraft") > 0 Then
  631. isMainEntry = False
  632. isBold = True
  633. ElseIf InStr(mainPara.Range.text, "Next") > 0 Then
  634. isMainEntry = False
  635. isBold = False
  636. Else
  637. isMainEntry = True
  638. isBold = False
  639. End If
  640.  
  641. FormatParagraph mainPara, isMainEntry, isBold
  642. Next mainPara
  643. End With
  644. End Sub
  645.  
  646.  
Advertisement
Add Comment
Please, Sign In to add comment