Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 06-15-2019, 03:45 AM
macropod's Avatar
macropod macropod is offline If condition not working. Windows 7 64bit If condition not working. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

A better way (IMHO) would be:
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
 Application.ScreenUpdating = False
 Dim i As Long, StrDetails As String, StrOffice As String, StrHdFt As String
 With CCtrl
  If .Title = "OFFICE" Then
    For i = 1 To .DropdownListEntries.Count
      If .DropdownListEntries(i).Text = .Range.Text Then
        StrDetails = .DropdownListEntries(i).Value
        Exit For
      End If
    Next
    If StrDetails = "" Then StrDetails = "||"
    StrOffice = Split(StrDetails, "|")(0)
     With ActiveDocument.SelectContentControlsByTitle("A-OFFICE")(1)
      .LockContents = False
      .Range.Text = StrOffice
      .LockContents = False
     End With
    With ActiveDocument.SelectContentControlsByTitle("A-OFFICE")(2)
      .LockContents = False
      .Range.Text = StrOffice
      .LockContents = True
    End With
    With ActiveDocument.SelectContentControlsByTitle("A-OFFICE")(3)
      .LockContents = False
      .Range.Text = StrOffice
      .LockContents = True
    End With
    With ActiveDocument.SelectContentControlsByTitle("OFFICEADDRESS")(1)
      .LockContents = False
      .Range.Text = Replace(Split(StrDetails, "|")(1), ";", Chr(11))
      .LockContents = True
    End With
    Select Case StrOffice
      Case "OFFICENAME1": StrHdFt = "OFFICENAME1 HEADER|OFFICENAME1 FOOTER1|OFFICENAME1 FOOTER2|OFFICENAME1 FOOTER3"
      Case "OFFICENAME2": StrHdFt = "OFFICENAME1 HEADER|OFFICENAME1 FOOTER1|OFFICENAME1 FOOTER2|OFFICENAME1 FOOTER3"
      Case Else: StrHdFt = "|||"
    End Select
    With ActiveDocument.SelectContentControlsByTitle("OFFICEHEAD")(1)
      .LockContents = False
      .Range.Text = Split(StrHdFt, "|")(0)
      .LockContents = True
    End With
    With ActiveDocument.SelectContentControlsByTitle("A-FOOTER1")(1)
      .LockContents = False
      .Range.Text = Split(StrHdFt, "|")(1)
      .LockContents = True
    End With
    With ActiveDocument.SelectContentControlsByTitle("A-FOOTER2")(1)
      .LockContents = False
      .Range.Text = Split(StrHdFt, "|")(2)
      .LockContents = True
    End With
    With ActiveDocument.SelectContentControlsByTitle("A-FOOTER3")(1)
      .LockContents = False
      .Range.Text = Split(StrHdFt, "|")(3)
      .LockContents = True
    End With
  End If
 End With
 Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
if then else;case



Similar Threads
Thread Thread Starter Forum Replies Last Post
If condition related query... LearnerExcel Excel 1 03-12-2018 01:37 AM
If condition not working. How to use if condition to for this ... LearnerExcel Excel 1 12-19-2016 02:14 PM
If condition not working. Use Two (concatenate) Fields If Condition Is Met (If... Then... Else) SoonerLater Mail Merge 1 09-30-2015 05:40 PM
If condition not working. Condition formating for date? yabbah Excel 2 05-31-2012 12:38 PM
If condition not working. check with condition karti Word 2 03-15-2011 06:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:44 PM.


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