• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 60
  • Last Modified:

VBscript ability to control formatting?

Can VBscript control things like formatting (bolding, adding cell borders, wrapping text on certain fields, etc.). If so, what functions are available?
0
Judy Deo
Asked:
Judy Deo
2 Solutions
 
Wayne Taylor (webtubbs)Commented:
The broad answer is yes. VBA can do just about everything you can do manually in Excel, plus more. For specifics about formatting cells it's probably best to point you toward the official documentation of the Range object. Browse through the Properties at the bottom.

https://msdn.microsoft.com/en-us/library/office/ff838238.aspx?f=255&MSPPError=-2147217396
0
 
MacroShadowCommented:
You probably mean VBA not VBscript which is a standalone scripting language.
The answer to your question is anything you can do using Excel's GUI can be done using VBA.
Here are some examples for formatting the font:
' set font properties
Selection.Font.Name = "Rockwell Condensed"
Selection.Font.Bold = True
Selection.Font.Italic = True
Selection.Font.Strikethrough = True
Selection.Font.Size = 45
Selection.Font.ThemeColor = 5
Selection.Font.Color = vbBlue

Open in new window

p.s. instead of selection you can (and should use the range object, i.e.
' set font properties
Range("A1").Font.Name = "Rockwell Condensed"
Range("A1:B5").Font.Bold = True
Range("A1:B5").Font.Italic = True
Range("A1:B5").Font.Strikethrough = True
Range("A1:B5").Font.Size = 45
Range("A1:B5").Font.ThemeColor = 5
Range("A1:B5").Font.Color = vbBlue

Open in new window

0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now