Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub cmb_Test_Click()
- Dim ExtensionChecked As Boolean
- Dim InspectionType As String
- ' Capture values from the userform
- ExtensionChecked = cb_Extension.Value
- InspectionType = cmb_InspectionType.Value
- ' Call the UpdateMaintenanceBody subroutine
- UpdateMaintenanceBody ExtensionChecked, InspectionType
- End Sub
- Public Sub UpdateMaintenanceBody(ByVal ExtensionValue As Boolean, ByVal InspectionTypeValue As String)
- Dim doc As Document
- Dim WPFull As String
- Dim frm As ReleaseHub ' Change UserForm to your actual userform instance name
- ' Get the active document
- Set doc = ActiveDocument
- ' Check if values are populated
- If InspectionTypeValue = "" Then
- MsgBox "Please select Inspection Type!", vbExclamation
- Exit Sub
- End If
- ' Ensure the userform is loaded and accessible
- Set frm = ReleaseHub ' Reference your userform
- WPFull = frm.BuildWPFull ' Get the full WP string using the userform function
- ' Access txt_Extension value from the userform
- Dim ExtensionText As String
- ExtensionText = frm.txt_Extension.Value ' Get the value of the textbox from the userform
- ' Check if txt_Extension.Value is set
- If IsEmpty(ExtensionText) Then
- MsgBox "Extension value is not set!", vbExclamation
- Exit Sub
- End If
- ' Determine maintenance detail based on extension checkbox
- If ExtensionValue = True Then
- ' Update content control with the new text
- 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"
- Else
- doc.SelectContentControlsByTag("text_MaintBody")(1).Range.text = Trim(InspectionTypeValue) & " carried out"
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment