Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
4,882 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I have a user form which updates around 650 Content Controls in the Word Document. It works fine when the Track Changes function is disabled. When the user would like to Track Changes they are getting an error message 5097 in SubmitEndorsement function. Content Control labels are not locked in the file.
Private Sub b_Submit_Click()
On Error GoTo ErrHandler
For Each openDoc In Application.Documents
openDoc.Activate
If ActiveDocument.SelectContentControlsByTag("UniqueDocN").Count > 0 Then
If ActiveDocument.SelectContentControlsByTag("UniqueDocN").Item(1).Range.Text = UniqueDocNumber Then
SubmitEndorsement
End If
End If
Next openDoc
Adios:
Exit Sub
ErrHandler:
MsgBox "Uh oh - an error has occurred with Function UserForm_Submit ."
Resume Adios
Resume
End Sub
Sub SubmitEndorsement()
On Error GoTo ErrHandler
Call updateControl("CCProgramme", "txt_Programme")
Adios:
Exit Sub
ErrHandler:
MsgBox "Uh oh - an error has occurred with Function SubmitEndorsement."
Resume Adios
Resume
End Sub
Sub updateControl(ctl_name As String, txtBox_name As String)
With ActiveDocument
If UserForm.Controls(txtBox_name).value <> .SelectContentControlsByTag(ctl_name).Item(1).Range.Text Then
.SelectContentControlsByTag(ctl_name).Item(1).Range.Text = UserForm.Controls(txtBox_name).value
End If
End With
End Sub
Why try checking exists SelectContentControlsByTag("UniqueDocN")
and then you want to use another "CCProgramme", "txt_Programme" to modified
Regards
SelectContentControlsByTag("UniqueDocN") is checking the uniqueId to update the correct file. For example I have 2 files with the content control "UniqueDocN" open and only the file which has a correct "UniqueDocN" will be updated.