C# Snippets


Language_Change

Public Sub Language_Change(ByRef objDocument As Word.Document, _
ByVal sDocumentType As String, _
ByVal enLanguageID As Word.WdLanguageID)

Dim bdocumentprotected As Boolean
Dim blnTrackChangesOn As Boolean
Dim myStoryRange As Word.Range

Try
Call Tracer_Add2("SUBROUTINE", System.Reflection.MethodBase.GetCurrentMethod.Name & " start")
If My.Settings.ERROR_OCCURRED = True Then Exit Sub

blnTrackChangesOn = objDocument.TrackRevisions
objDocument.TrackRevisions = blnTrackChangesOn

If (modSpecific.Document_IsValidAndProtected(objDocument) = True) Then
bdocumentprotected = True
Call modWordObjectModel.Document_Unprotect(objDocument, gsDOCUMENTPASSWORD, False)
End If

objDocument.ShowSpellingErrors = True

For Each myStoryRange In objDocument.StoryRanges

myStoryRange.LanguageID = enLanguageID
Do While Not (myStoryRange.NextStoryRange Is Nothing)
myStoryRange = myStoryRange.NextStoryRange
myStoryRange.LanguageID = enLanguageID
Loop

Next myStoryRange

objDocument.TrackRevisions = blnTrackChangesOn

Exit Sub

Catch ex As System.Exception
Call modMessages.Exception(System.Reflection.MethodBase.GetCurrentMethod, Nothing, ex)
Finally
If (bdocumentprotected = True) Then
Call modWordObjectModel.Document_Protect(objDocument, gsDOCUMENTPASSWORD, False)
End If
End Try
End Sub

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top