MS Word / how to format elements in an array: bold, strikethru, etc

KenWit

Board Regular
Joined
Nov 21, 2011
Messages
68
This works for converting elements in an array to uppercase.
Is there a way to do this for making the elements bold?
Doesn't seem so as it'd have to read something like,
ary(n) = selection.characters(n).font.bold = true
Just wondering. Trying to learn VBA one function at a time.

Private Sub CommandButton89_Click()
Dim ary() As String
For Each c In Selection.Characters
N = N + 1
ReDim Preserve ary(N)
ary(n) = ucase(selection.characters(n))
Next c
Selection.TypeText Text:=Join(ary, "")
End Sub

What I ultimately have in view is to display the array to replace text in a msgbox as a preview
before replacing the text in a document with it. Then I can get an idea of how it looks.
Something like that might be useful with some work.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Array strings can't hold formatting attributes. Your uppercase example misunderstands the fact that uppercase strings are just as much composed of characters as lowercase strings.
 
Upvote 0

Forum statistics

Threads
1,225,656
Messages
6,186,245
Members
453,343
Latest member
hacigultekin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top