Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-04-2023, 12:12 PM
kevinbradley57 kevinbradley57 is offline Unable to abbreviate "Strong" Windows 7 64bit Unable to abbreviate "Strong" Office 2010 64bit
Advanced Beginner
Unable to abbreviate "Strong"
 
Join Date: Jul 2017
Posts: 84
kevinbradley57 is on a distinguished road
Default Unable to abbreviate "Strong"


I have a dropdown content control in a table cell. The font and background color change based on the selection made. One of the dropdown options is "Strong" and that works fine. I have a request to abbreviate it as "Str" but when I make that change in the VB and in the dropdown, either the background and font colors are both white or it's returning a blank cell (I can't tell which).
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
With ContentControl
      Case "CE"
      Select Case .Range.Text
        Case "Strong": .Range.Cells(1).Shading.BackgroundPatternColor = 6299648: .Range.Cells(1).Range.Font.ColorIndex = wdWhite
        Case "Weak": .Range.Cells(1).Shading.BackgroundPatternColor = 4739264: .Range.Cells(1).Range.Font.ColorIndex = wdWhite
        Case "Sat": .Range.Cells(1).Shading.BackgroundPatternColor = 5880731: .Range.Cells(1).Range.Font.ColorIndex = wdBlack
        Case "IN": .Range.Cells(1).Shading.BackgroundPatternColor = 5232127: .Range.Cells(1).Range.Font.ColorIndex = wdBlack
        Case Else: .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight
      End Select
    Case Else
  End Select
End With
End Sub
Reply With Quote
  #2  
Old 05-04-2023, 03:47 PM
Guessed's Avatar
Guessed Guessed is offline Unable to abbreviate "Strong" Windows 10 Unable to abbreviate "Strong" Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
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

Your code is non-functioning. If I correct the missing line to allow it to work we can also allow two options for Str or Strong
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  With ContentControl
    Select Case .Title
        Case "CE"
          Select Case .Range.Text
            Case "Strong", "Str": .Range.Cells(1).Shading.BackgroundPatternColor = 6299648: .Range.Cells(1).Range.Font.ColorIndex = wdWhite
            Case "Weak": .Range.Cells(1).Shading.BackgroundPatternColor = 4739264: .Range.Cells(1).Range.Font.ColorIndex = wdWhite
            Case "Sat": .Range.Cells(1).Shading.BackgroundPatternColor = 5880731: .Range.Cells(1).Range.Font.ColorIndex = wdBlack
            Case "IN": .Range.Cells(1).Shading.BackgroundPatternColor = 5232127: .Range.Cells(1).Range.Font.ColorIndex = wdBlack
            Case Else: .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight
          End Select
    End Select
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 05-04-2023, 05:12 PM
kevinbradley57 kevinbradley57 is offline Unable to abbreviate "Strong" Windows 7 64bit Unable to abbreviate "Strong" Office 2010 64bit
Advanced Beginner
Unable to abbreviate "Strong"
 
Join Date: Jul 2017
Posts: 84
kevinbradley57 is on a distinguished road
Default Andrew - Here's the file.

Andrew - Thanks for the quick response. I applied your suggestions but the colors only work right when "Strong" is selected. Selecting "Str" does not work. If you have time, the attached file is a one-page Word doc with the problematic table. The blank cell (bottom right) should be showing "Str" with white font on a dark blue back ground.
Attached Files
File Type: docm Problem table.docm (90.4 KB, 3 views)
Reply With Quote
  #4  
Old 05-04-2023, 07:30 PM
Guessed's Avatar
Guessed Guessed is offline Unable to abbreviate "Strong" Windows 10 Unable to abbreviate "Strong" Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
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

The code in your attached document hasn't got a mention of "Str" so the result will be the Case Else is the line making changes. In that line you set the background color but don't touch the font color so if it was white before you got there it is now white font on a white background.

If you want Str to be treated the same as Strong, include it in the Case condition like I did

If you want Case Else to set the background AND the font then change that line to
Code:
Case Else: .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight: .Range.Cells(1).Range.Font.ColorIndex = wdBlack
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 05-05-2023, 07:32 AM
kevinbradley57 kevinbradley57 is offline Unable to abbreviate "Strong" Windows 7 64bit Unable to abbreviate "Strong" Office 2010 64bit
Advanced Beginner
Unable to abbreviate "Strong"
 
Join Date: Jul 2017
Posts: 84
kevinbradley57 is on a distinguished road
Default

Andrew - Thanks for your assistance. Much appreciated.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003: VBA "Function" causes "#VALUE!" errors after running "insert/delete row" custom macro Matt C Excel Programming 2 01-08-2022 06:03 AM
Unable to customize ribbon, remove "Cell Styles" pjs15 Excel 1 08-21-2020 08:01 AM
Unable to abbreviate "Strong" When applying styles word is automatically reverting to "strong" style partway through my document Victoria S Word 3 11-17-2015 12:51 PM
Message "Unable to read file" when clicking on the Excel icon roundman Excel 3 12-03-2014 04:28 PM
Unable to "Shift cells down" on unprotected area in a protected worksheet ricky0309 Excel 0 08-14-2014 01:51 AM

Other Forums: Access Forums

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


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