JustJoe21

Untitled

Dec 19th, 2024 (edited)
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | Help | 0 0
  1. Private Sub cmb_Test_Click()
  2. Dim ExtensionChecked As Boolean
  3. Dim InspectionType As String
  4.  
  5. ' Capture values from the userform
  6. ExtensionChecked = cb_Extension.Value
  7. InspectionType = cmb_InspectionType.Value
  8.  
  9. ' Call the UpdateMaintenanceBody subroutine
  10. UpdateMaintenanceBody ExtensionChecked, InspectionType
  11. End Sub
  12.  
  13.  
  14. Public Sub UpdateMaintenanceBody(ByVal ExtensionValue As Boolean, ByVal InspectionTypeValue As String)
  15. Dim doc As Document
  16. Dim WPFull As String
  17. Dim frm As ReleaseHub ' Change UserForm to your actual userform instance name
  18.  
  19. ' Get the active document
  20. Set doc = ActiveDocument
  21.  
  22. ' Check if values are populated
  23. If InspectionTypeValue = "" Then
  24. MsgBox "Please select Inspection Type!", vbExclamation
  25. Exit Sub
  26. End If
  27.  
  28. ' Ensure the userform is loaded and accessible
  29. Set frm = ReleaseHub ' Reference your userform
  30. WPFull = frm.BuildWPFull ' Get the full WP string using the userform function
  31.  
  32. ' Access txt_Extension value from the userform
  33. Dim ExtensionText As String
  34. ExtensionText = frm.txt_Extension.Value ' Get the value of the textbox from the userform
  35.  
  36.  
  37. ' Check if txt_Extension.Value is set
  38. If IsEmpty(ExtensionText) Then
  39. MsgBox "Extension value is not set!", vbExclamation
  40. Exit Sub
  41. End If
  42.  
  43. ' Determine maintenance detail based on extension checkbox
  44. If ExtensionValue = True Then
  45. ' Update content control with the new text
  46. doc.SelectContentControlsByTag("text_MaintBody")(1).Range.text = cmb_InspectionType.Value & " and all related tasks in WP " & WPFull & " extended 10 hours and now due at " & ExtensionText & " Hrs"
  47. Else
  48. doc.SelectContentControlsByTag("text_MaintBody")(1).Range.text = Trim(InspectionTypeValue) & " carried out"
  49. End If
  50. End Sub
  51.  
  52.  
Tags: VisualBasic
Advertisement
Add Comment
Please, Sign In to add comment