Thread: [Solved] If condition not working.
View Single Post
 
Old 06-15-2019, 12:13 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Presumably because whatever Split(StrDetails, "|")(0) contains - and populates "A-OFFICE" with - is neither "OFFICE01" nor "OFFICE02".

Based on what you've posted, your code would be better expressed as:
Code:
With ActiveDocument.SelectContentControlsByTitle("A-OFFICE")(1)
    .LockContents = False
    .Range.Text = Split(StrDetails, "|")(0)
    .LockContents = False
End With
With ActiveDocument.SelectContentControlsByTitle("OFFICEHEAD")(1)
  .LockContents = False
  Select Case Split(StrDetails, "|")(0)
    Case "OFFICE01": .Range.Text = "OFFICE01 HEADER"
    Case "OFFICE02": .Range.Text = "OFFICE02 HEADER"
    Case Else: .Range.Text = "JUST HEADER"
  End Select
  .LockContents = True
End With
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote