Cannot Print A Word In Bold Using Word Basic

M

Mark1110

I inherited a program that is written in word basic using Microsoft Word
2003. I have a variable that prints in a Word document:

Hinp$ = "$250^p^tper day ^p^t up to 3 day maximum"

This line works fine, it prints in normal text. What the user wants is to
have the word "maximum" in bold. I tried ^b, [bold], and a few other things
that either doesn't work or I get a syntax error. Both Microsofts web site
and the internet didn't help me much. Does anyone know how to use bold in a
variable so only the word maximum prints.

Thanks,

Mark
 
R

Russ

Mark,
If this is not for html, but a regular document...
Word doesn't recognize formatting code in a variable.
You could use these lines:
selection.typetext "$250^p^tper day ^p^t up to 3 day "
selection.font.bold = true
selection.typetext "maximum"
selection.font.bold = false


^p^tper day [plain]^p^t -will show as literal text.

If you want a tab, you concatenate a vbTab into a string using a &
character.
selection.typetext "Before tab " & vbTab & "after tab."

vbCr is a paragraph mark, etc.
[QUOTE]
I inherited a program that is written in word basic using Microsoft Word
2003. I have a variable that prints in a Word document:

Hinp$ = "$250^p^tper day [plain]^p^t up to 3 day maximum"

This line works fine, it prints in normal text. What the user wants is to
have the word "maximum" in bold. I tried ^b, [bold], and a few other things
that either doesn't work or I get a syntax error. Both Microsofts web site
and the internet didn't help me much. Does anyone know how to use bold in a
variable so only the word maximum prints.

Thanks,

Mark[/QUOTE]
 
R

Russ

Mark,
Use Alt/F11 to go into Word VBA editor.
Use menu Help/Visual Basic Help
Search for the word
wordbasic
For information on converting code to VBA.


I inherited a program that is written in word basic using Microsoft Word
2003. I have a variable that prints in a Word document:

Hinp$ = "$250^p^tper day ^p^t up to 3 day maximum"

This line works fine, it prints in normal text. What the user wants is to
have the word "maximum" in bold. I tried ^b, [bold], and a few other things
that either doesn't work or I get a syntax error. Both Microsofts web site
and the internet didn't help me much. Does anyone know how to use bold in a
variable so only the word maximum prints.

Thanks,

Mark[/QUOTE]
 
H

Helmut Weber

Hi Russ,

just another footnote,
in former times you could sent a string
containing control characters,
which were all preceded by escape,
to the printer,
causing the printer to print backwards, bold etc.
even pulling the endless paper back,
until all was a mess.

The code looks as if it was from that time.

Still worse with then high-tech line printers,
located in the next air-conditioned room,
which ejected 200 pages before you could pull the plug out.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

Russ

You're right Helmut, I assumed he just wanted his code to produce text in a
document. We still send escape sequences to printers to format their output
on some printers from Unix boxes at work. But they looked more like ^[Q10 or
ESC &l10.
 

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