BBO Discussion Forums: Inserting Color Suit Symbols in Word - BBO Discussion Forums

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Inserting Color Suit Symbols in Word VBA Code

#21 User is offline   steve2005 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 3,148
  • Joined: 2010-April-22
  • Gender:Male
  • Location:Hamilton, Canada
  • Interests:Bridge duh!

Posted 2014-June-08, 12:03

View PostfromageGB, on 2014-June-08, 06:52, said:

I have tried echognome's idea of assigning a macro for each coloured symbol to a key, and this is clean as it works with any trailing or leading characters, but I cannot assign them to useful keys. For example, as my keyboard has function keys in groups of four, it would be good to assign F1=spades, F2=hearts, F3=diamonds, F4=clubs. However, while I can do this for F2/3/4 I cannot reassign F1 from its meaning of "help". Similarly there is a reserved key in each of the other blocks of four. While I could use shift in conjunction with an F key, this is not convenient, and I'll stick to my 28 autocorrects.


I use the shortcut keys. can set them by clicking on symbol button them shortcut key in word

have assigned alt-q to clubs, alt-w to diamonds, alt-e to hearts and alt-r to spades

cant do colors that way, autocorrect seems to be the only way but works good with black.

QUESTION: what are the standard colors assigned to the various suits?



Sarcasm is a state of mind
0

#22 User is offline   fromageGB 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 2,679
  • Joined: 2008-April-06

Posted 2014-June-08, 12:37

View Poststeve2005, on 2014-June-08, 12:03, said:

QUESTION: what are the standard colors assigned to the various suits?

You will be using Word, so I probably can't help you as my libreoffice may have different font colours. FWIW I like :
clubs = green ; position in the drop-down font colour array 3,1 (along,down starting with 1) html color (html can't speak English) "#008000"
diamonds = orange2 ; 6,11 "#dc2300"
hearts = chart11 ; 2,14 #ff6633"
spades = light blue ; 2,2 "#0000ff"
as these to me look the right intensity on both screen and paper, with a clear distinction between the diamond/heart colours.

Any answerers with Word ?

BTW if you are happy with a double fingered/handed shortcut key action, such as alt-q, then macros do give the colour, as has been described.

Edit : html colours added, and these will be the same in all software
0

#23 User is offline   steve2005 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 3,148
  • Joined: 2010-April-22
  • Gender:Male
  • Location:Hamilton, Canada
  • Interests:Bridge duh!

Posted 2014-June-08, 13:27

using the autocorrect for !c I get a superfluous line.



Sarcasm is a state of mind
0

#24 User is offline   Cascade 

  • PipPipPipPipPipPipPipPip
  • Group: Yellows
  • Posts: 6,760
  • Joined: 2003-July-22
  • Gender:Male
  • Location:New Zealand
  • Interests:Juggling, Unicycling

Posted 2014-June-08, 16:19

View Poststeve2005, on 2014-June-08, 13:27, said:

using the autocorrect for !c I get a superfluous line.


I would think the most likely reason is that you have an end of line selected when you created the auto correct.

Position your cursor before or after the symbol that you want and select one character by using shift and right or left arrow as appropriate is one way to select only one character. Sometimes you need to be careful if the character is at the end of a line or paragraph as word will select the marker. You can get word to show these paragraph markers.
Wayne Burrows

I believe that the USA currently hold only the World Championship For People Who Still Bid Like Your Auntie Gladys - dburn
dunno how to play 4 card majors - JLOGIC
True but I know Standard American and what better reason could I have for playing Precision? - Hideous Hog
Bidding is an estimation of probabilities SJ Simon

#25 User is offline   steve2005 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 3,148
  • Joined: 2010-April-22
  • Gender:Male
  • Location:Hamilton, Canada
  • Interests:Bridge duh!

Posted 2014-June-08, 19:54

View PostCascade, on 2014-June-08, 16:19, said:

I would think the most likely reason is that you have an end of line selected when you created the auto correct.

Position your cursor before or after the symbol that you want and select one character by using shift and right or left arrow as appropriate is one way to select only one character. Sometimes you need to be careful if the character is at the end of a line or paragraph as word will select the marker. You can get word to show these paragraph markers.

yes, thought of that, isolated it , still doesn't work

when I use plain text is fine but black when I use formatting a line gets added which is useless




Sarcasm is a state of mind
0

#26 User is offline   Lorne50 

  • PipPipPip
  • Group: Full Members
  • Posts: 65
  • Joined: 2013-August-19

Posted 2014-June-14, 03:18

View PostEchognome, on 2010-February-28, 14:35, said:

I am trying to update some system notes and trying to insert color suit symbols in my document. I can think of two ways to do this efficiently and wondered what other people have done.



By far the best IMO is to use auto text. Just put a symbol on the page, format it as symbol font and the right colour then go to insert auto text and add it to the list and assign a keyboard shortcut to it. For me Alt-C, alt-D, alt-H and alt-S insert correctly coloured and formatted symbols and allows me to type at normal speed when inserting them.
0

#27 User is offline   meto 

  • PipPip
  • Group: Members
  • Posts: 12
  • Joined: 2004-August-29
  • Location:Istanbul / Turkey

Posted 2017-December-12, 01:34

View PostEchognome, on 2010-February-28, 14:35, said:

I am trying to update some system notes and trying to insert color suit symbols in my document. I can think of two ways to do this efficiently and wondered what other people have done.

Method 1 - Record a Macro for inserting each suit symbol and assign a hotkey to each macro. Here's the code I wrote for this method:

Sub InsertClub()
Selection.Font.Color = wdColorGreen
Selection.InsertSymbol Font:="Symbol", CharacterNumber:=-3929, Unicode:=True
Selection.Font.Color = wdColorAutomatic
End Sub
Sub InsertDiamond()
Selection.Font.Color = wdColorOrange
Selection.InsertSymbol Font:="Symbol", CharacterNumber:=-3928, Unicode:=True
Selection.Font.Color = wdColorAutomatic
End Sub
Sub InsertHeart()
Selection.Font.Color = wdColorRed
Selection.InsertSymbol Font:="Symbol", CharacterNumber:=-3927, Unicode:=True
Selection.Font.Color = wdColorAutomatic
End Sub
Sub InsertSpade()
Selection.Font.Color = wdColorBlack
Selection.InsertSymbol Font:="Symbol", CharacterNumber:=-3926, Unicode:=True
Selection.Font.Color = wdColorAutomatic
End Sub

Method 2 - Use the AutoCorrect to insert the suit symbols and then write a macro to go through the entire document and replace all suit symbols with the same symbol but with the respective colors. The advantage of this method is you can use !c, !d, !h, and !s to edit the suit symbols in the document and then do one sweep at the end to attach the colors. The disadvantage is that it doesn't seem to work as I expect it to. Some of the symbols don't get converted and I don't understand why. Anyway, here is the code I have (mainly from recording and replacing code).

Sub SuitColors()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(9827)
.Replacement.Text = ChrW(9827)
.Replacement.Font.Color = wdColorGreen
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(9830)
.Replacement.Text = ChrW(9830)
.Replacement.Font.Color = wdColorOrange
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(9829)
.Replacement.Text = ChrW(9829)
.Replacement.Font.Color = wdColorRed
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(9824)
.Replacement.Text = ChrW(9824)
.Replacement.Font.Color = wdColorAutomatic
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Any thoughts from other people? What has been successful for you? Any other methods that may work better?

0

#28 User is offline   meto 

  • PipPip
  • Group: Members
  • Posts: 12
  • Joined: 2004-August-29
  • Location:Istanbul / Turkey

Posted 2017-December-12, 01:43

I managed to have method-1 work perfectly well, however, I couldn't have the method-2 work... Are there any further tips to have it work? I have actually copied the code and pasted in the modules then just run the code but no suit color has changed in my document.
What I really need to do is to have the TOC back to its original form after it has turned all suit colors to black; by default when I happen to update it.

Any suggestions are welcome !
0

#29 User is offline   gordontd 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 4,485
  • Joined: 2009-July-14
  • Gender:Male
  • Location:London

Posted 2017-December-12, 03:47

Here's what I use after writing text with Sx, Hx, Dx, Cx instead of the symbols for Spades, Hearts, Diamonds, Clubs.

Sub SuitXcolours()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Cx"
.Replacement.Text = ChrW(9827)
.Replacement.Font.Color = wdColorGreen
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Dx"
.Replacement.Text = ChrW(9830)
.Replacement.Font.Color = wdColorOrange
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Hx"
.Replacement.Text = ChrW(9829)
.Replacement.Font.Color = wdColorRed
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Sx"
.Replacement.Text = ChrW(9824)
.Replacement.Font.Color = wdColorBlue
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Gordon Rainsford
London UK
0

#30 User is offline   meto 

  • PipPip
  • Group: Members
  • Posts: 12
  • Joined: 2004-August-29
  • Location:Istanbul / Turkey

Posted 2017-December-14, 02:45

your putting x next to C, D, H, S seems to solve only one problem... e.i. converting Texts to the suits with the colors we want... However, it does not help changing those symbols back to the original after TOC have changed all colors to black..

So what we actually need is be able to change the color of symbols from whatever color they have been changed into back to their original colors as we want them..

Any code for clearing the wrong format and getting them back to the original state with the right colors?
0

#31 User is offline   gordontd 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 4,485
  • Joined: 2009-July-14
  • Gender:Male
  • Location:London

Posted 2017-December-14, 03:47

View Postmeto, on 2017-December-14, 02:45, said:

your putting x next to C, D, H, S seems to solve only one problem... e.i. converting Texts to the suits with the colors we want... However, it does not help changing those symbols back to the original after TOC have changed all colors to black..

So what we actually need is be able to change the color of symbols from whatever color they have been changed into back to their original colors as we want them..

Any code for clearing the wrong format and getting them back to the original state with the right colors?

I haven't tried this, but logically I would have thought editing the above procedure for all four as below would do it:

Quote

Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(9824)
.Replacement.Font.Color = wdColorBlue
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Gordon Rainsford
London UK
0

#32 User is offline   gordontd 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 4,485
  • Joined: 2009-July-14
  • Gender:Male
  • Location:London

Posted 2017-December-14, 05:03

I have now tried it and it worked fine, so the full procedure would be:

Quote

Sub SuitColours()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(9827)
.Replacement.Font.Color = wdColorGreen
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(9830)
.Replacement.Font.Color = wdColorOrange
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(9829)
.Replacement.Font.Color = wdColorRed
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(9824)
.Replacement.Font.Color = wdColorBlue
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub


Change the colours if you prefer.
Gordon Rainsford
London UK
1

#33 User is offline   Tramticket 

  • PipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 2,070
  • Joined: 2009-May-03
  • Gender:Male
  • Location:Kent (Near London)

Posted 2017-December-14, 05:26

Simple solution:

(1) insert the suit symbols as black - I set up [alt]s, [alt]h, [alt]d and [alt]c for this.
(2) once you have finished the document, use the replace function to add the colour formating. Select the Replace from the toolbar; type ♥ into both the "Find what" and "Replace with" boxes; click on More>>; then click on Format, Font and select the colour red; click on replace all. Repeat for the diamond suit. [Personally I prefer to leave clubs and spades black!].

No macros needed.
0

#34 User is offline   r_pakker 

  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 2008-March-10

Posted 2019-August-27, 05:39

View PostEchognome, on 2010-February-28, 14:35, said:

I am trying to update some system notes and trying to insert color suit symbols in my document. I can think of two ways to do this efficiently and wondered what other people have done.

Method 1 - Record a Macro for inserting each suit symbol and assign a hotkey to each macro. Here's the code I wrote for this method:

Sub InsertClub()
Selection.Font.Color = wdColorGreen
Selection.InsertSymbol Font:="Symbol", CharacterNumber:=-3929, Unicode:=True
Selection.Font.Color = wdColorAutomatic
End Sub
Sub InsertDiamond()
Selection.Font.Color = wdColorOrange
Selection.InsertSymbol Font:="Symbol", CharacterNumber:=-3928, Unicode:=True
Selection.Font.Color = wdColorAutomatic
End Sub
Sub InsertHeart()
Selection.Font.Color = wdColorRed
Selection.InsertSymbol Font:="Symbol", CharacterNumber:=-3927, Unicode:=True
Selection.Font.Color = wdColorAutomatic
End Sub
Sub InsertSpade()
Selection.Font.Color = wdColorBlack
Selection.InsertSymbol Font:="Symbol", CharacterNumber:=-3926, Unicode:=True
Selection.Font.Color = wdColorAutomatic
End Sub

Method 2 - Use the AutoCorrect to insert the suit symbols and then write a macro to go through the entire document and replace all suit symbols with the same symbol but with the respective colors. The advantage of this method is you can use !c, !d, !h, and !s to edit the suit symbols in the document and then do one sweep at the end to attach the colors. The disadvantage is that it doesn't seem to work as I expect it to. Some of the symbols don't get converted and I don't understand why. Anyway, here is the code I have (mainly from recording and replacing code).

Sub SuitColors()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(9827)
.Replacement.Text = ChrW(9827)
.Replacement.Font.Color = wdColorGreen
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(9830)
.Replacement.Text = ChrW(9830)
.Replacement.Font.Color = wdColorOrange
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(9829)
.Replacement.Text = ChrW(9829)
.Replacement.Font.Color = wdColorRed
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ChrW(9824)
.Replacement.Text = ChrW(9824)
.Replacement.Font.Color = wdColorAutomatic
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Any thoughts from other people? What has been successful for you? Any other methods that may work better?

Hello 'Echonome'

Since long I avoid making use of the 'symbol font'. Not everybody has this font on his/her device.
For no trump I use the 'white sun' symbol. And I added 'double' and 'redouble' macro's.
'.InsertAfter ""' is added because it stops continuing sometimes typing in the wrong color when you have deleted text after a coloured symbol.
I coupled these macro's to free <ALT-Key>'s.


Sub klaver()
'
' klaver/club
'
'
With Selection
.Font.Color = wdColorBlack
.TypeText (ChrW(9827))
.Font.Color = wdColorAutomatic
.InsertAfter ""
End With
End Sub

Sub ruiten()
'
' ruiten/diamond
'
With Selection
.Font.Color = wdColorRed
.TypeText (ChrW(9830))
.Font.Color = wdColorAutomatic
.InsertAfter ""
End With
End Sub

Sub harten()
'
' harten/heart
'
With Selection
.Font.Color = wdColorRed
.TypeText (ChrW(9829))
.Font.Color = wdColorAutomatic
.InsertAfter ""
End With
End Sub

Sub schoppen()
'
' schoppen/spade
'
With Selection
.Font.Color = wdColorBlack
.TypeText (ChrW(9824))
.Font.Color = wdColorAutomatic
.InsertAfter ""
End With
End Sub

Sub sans()
'
' sans/notrump
'
With Selection
.Font.Color = wdColorBrightGreen
.TypeText (ChrW(9788))
.Font.Color = wdColorAutomatic
.InsertAfter ""
End With


End Sub

Sub doublet()
'
' doublet/double
'
With Selection
.Font.Shading.BackgroundPatternColor = wdColorRed
.Font.Color = wdColorWhite
.TypeText ("X")
.Font.Shading.BackgroundPatternColor = wdColorAutomatic
.Font.Color = wdColorAutomatic
.InsertAfter ""
End With

End Sub
Sub redoublet()
'
' redoublet/redouble
'
'
With Selection
.Font.Shading.BackgroundPatternColor = wdColorBlue
.Font.Color = wdColorWhite
.TypeText ("XX")
.Font.Shading.BackgroundPatternColor = wdColorAutomatic
.Font.Color = wdColorAutomatic
.InsertAfter ""
End With

End Sub
0

#35 User is offline   barmar 

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • Group: Admin
  • Posts: 21,398
  • Joined: 2004-August-21
  • Gender:Male

Posted 2019-August-28, 09:15

View Postr_pakker, on 2019-August-27, 05:39, said:

Hello 'Echonome'

Echognome hasn't logged into the forum in 5 years, I don't think he'll see your reply.

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users