Problem with TextBoxes

B

ByB

Hello,

I am working in an app in Access/VBA, which has to create an Excel
report.

So I try to create the Excel file and write in it from Access.
I already created the report, and added to it 5 Text Boxes with the
following code (wsh being a sheet of my Excel report) :

wsh.Shapes.AddReportBox ....(some parameters go here)

and that works prefectly.

The problem now is that I neeed to write bold text in these textbox,
and I cannot find a way to do that from the Access VBA program.

Can somebody help me at this point ?

Thank you for any help !

--
"Ponce Pilate n'avait pas le sens de l'économie. On aurait pu très bien
en effet crucifier les gens à cinquante centimètres du sol. Ce qui
aurait été aussi efficace qu'à quatre mètres et aurait permis de ne pas
gaspiller du bois."
(Jean Yanne / 1933-2003 / Je suis un être exquis)
 
B

ByB

Steve Rindsberg avait prétendu :
The Excel macro recorder will give you quite a bit of help if you're not
familiar with the Excel object model.

Thank you very much for your answer. It helped me a lot.
 
S

Steve Rindsberg

So I try to create the Excel file and write in it from Access.
I already created the report, and added to it 5 Text Boxes with the
following code (wsh being a sheet of my Excel report) :

wsh.Shapes.AddReportBox ....(some parameters go here)

and that works prefectly.

The problem now is that I neeed to write bold text in these textbox,
and I cannot find a way to do that from the Access VBA program.

The Excel macro recorder will give you quite a bit of help if you're not
familiar with the Excel object model. I let it record the fun while I added a
rectangle, added some text to the rectangle and formatted it.

The code, as always, depends on working with the current selection, a bad idea,
so with a bit of modification we get this:

Dim oSh As Shape
' you might want to change that to Excel.Shape

Set oSh = ActiveSheet.Shapes.AddShape( params here )
' or in your case wsh.Shapes.AddShape etcetc

With oSh.TextFrame.Characters
.Text = "aslfjaldjfla"
With .Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 18
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With ' font
End With ' osh

If a PowerPoint geek can do it, so can you. <g>
 

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