Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 08-27-2020, 01:46 AM
Guessed's Avatar
Guessed Guessed is offline VBA to conditionally hide text by language/structure? Windows 10 VBA to conditionally hide text by language/structure? Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

OK, I see your sample has lots of section breaks and it appears that consistently your right column is content in a section that follows a column break. This pattern could break in a real document if a section continues to a new page but based on your sample, this code works to assign a different language to anything following a column break.
Code:
Sub SetLanguages()
  Dim aSect As Section, aRng As Range, lngPos As Long
  ActiveDocument.Range.LanguageID = wdGerman    'language for first column
  For Each aSect In ActiveDocument.Sections
    Set aRng = aSect.Range
    lngPos = InStr(aRng.Text, Chr(14))
    If lngPos > 0 Then
      aRng.MoveStart Unit:=wdCharacter, Count:=lngPos
      aRng.LanguageID = wdEnglishAUS            'language for second column
    End If
  Next aSect
End Sub
If you wanted to work with styles with languages assigned (and you should) you can change
aRng.LanguageID = wdEnglishAUS
to
aRng.Style= "Normal"
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to text heading1 text heading1 text? How to collapse or hide text in the middle of a line. TImer Word 7 08-10-2020 12:52 AM
VBA to conditionally hide text by language/structure? Conditionally Color Formatting Text selected from a dropdown list in Word 2010 pgammag Word 9 08-20-2019 04:17 PM
Conditionally hide parts of a document elaineAda Word VBA 0 04-01-2019 10:00 PM
Insert a text conditionally deboer Word 1 05-04-2014 03:35 PM
Header must toggle text & color + show count of conditionally formatted cells below Franktoon Excel 3 02-18-2014 02:10 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:48 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft