Making it "Look Pretty."

S

shen.git

Hi all,

I have no hardcore programming knowledge (HTML, CSS) but I've been
assigned to try to find this information. I'm an absolute newbie at
VBA, so the more basic the explanation, the better I will fare.

My father is working on a program in VBA that generates reports in
Word. He found a quick solution for that on the Web somewhere but
didn't have time to study it. It works, but now we're hoping to
generate some customization--make the resulting Word doc "Look Pretty."

We're looking for ways to change fonts, color table borders and
backgrounds--via the VBA code. My dad would prefer to avoid macros, and
put these specs in the VBA code. He found a way to change the color of
the initial headings to green but nothing below that changed. He
doesn't have the time to play with these, which is why he's handed it
over to me.



PS: Is there any way to assign classes the way one can in CSS?
 
C

Charles Kenyon

Learn about styles. Apply them.

BTW - macros = vba code.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide




--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
S

Shen

Thanks. I know how to make styles in Word. How do I get VBA to apply
them? Can you point me toward some links that will explain it?
 
H

Helmut Weber

Hi,

applying styles seems to be so basic,
that help is hard to find.

I definded three paragraph styles, based on normal:
PrgGreen with green font
PrgBlue with blue font
PrgRed with red font

The following applies the styles in the order
PrgGreen, PrgBlue, PrgRed to every paragraph in the doc.

paragraph 1 will be in green font
paragraph 2 will be in red font
paragraph 3 will be in blue font
paragraph 4 will be in green font
paragraph 5 will be in red font
paragraph 6 will be in blue font...

HTH

Option Explicit
Dim rDcm As Range ' the document's range
Dim oPrg As Paragraph ' a paragraph
Dim lCnt As Long ' a counter
' -------------------------------------
Sub Test()
lCnt = 0
Set rDcm = ActiveDocument.Range
For Each oPrg In rDcm.Paragraphs
lCnt = lCnt + 1
Select Case lCnt
Case 1: oPrg.Style = "PrgGreen"
Case 2: oPrg.Style = "Prgblue"
Case 3: oPrg.Style = "PrgRed"
End Select
If lCnt = 3 Then lCnt = 0
Next
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top