I have the following tabular information to be put in a Word document.
AAA 111
BBB 22222222222222
CCCCCC 33333
DDDD 444444444444444444444
EE 123
Could any one tell me how to do it in VB coding with bold font (no grid lines needed)
Thanks.
I have the following tabular information to be put in a Word document.
AAA 111
BBB 22222222222222
CCCCCC 33333
DDDD 444444444444444444444
EE 123
Could any one tell me how to do it in VB coding with bold font (no grid lines needed)
Thanks.
Try this.
[VBA] Option Explicit
Sub AddTable()
Dim Tbl As Table
Set Tbl = ActiveDocument.Tables.Add(Range:=Selection.Range, _
NumRows:=4, NumColumns:=2)
Tbl.Range.Font.Bold = True
Tbl.Cell(1, 1).Range.Text = "AAA"
Tbl.Cell(1, 2).Range.Text = "111"
End Sub
[/VBA]
Thanks.
A question - if I want the first column to be 20 characters only and the second to be 45 columns. How could I do the settings with the table "Tb1" ?
A new one challenge is I have the following format
How are you?
I have the pleasure of displaying the items as followed -
AAA 111
BBB 22222222222222
CCCCCC 33333
DDDD 444444444444444444444
EE 123
Thank you for visiting!
Have a good day.
Could you please tell me how the accomplish the above?
Thanks again for the help.
You could have the first and last text outside of the table. ??
One of my question is how to set the colum width?
Thanks.
You can use this:
[vba]
Tbl.Columns(1).Width = 20
[/vba]
Thanks again!
Last question for the text lines (other than table), how I could put font for them
eg. How are you?
I have the pleasure of displaying the items as followed -
For the above two lines I want to have font (12) and bold face .
THANKS!
Try this.
[vba]
Selection.Font.Bold = True
Selection.TypeText Text:="Test"
[/vba]
Could ask another one? Greedy ..
For this ..
Selection.Font.Bold = True
Selection.TypeText Text:="Test"
How to change alignment (like Left/Center/Right)?
THANKS!
Hi,
Try:[vba]
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft[/vba]
This sort of stuff can easily be recorded with the macro recorder and this will save you time looking for answers.
Go to Tools/Macro/Record macro. Perform the actions you need and stop the recorder. After that a new module (NewMacros) is created with your recorded code.
This recorded code is not the neatest in the book but it can sure help you find your way arround Word.
HTH,
_________
Groetjes,
Joost Verdaasdonk
M.O.S. Master
Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
(I don't answer questions asked through E-mail or PM's)
A big THANKS to all!
You're Welcome
Take Care
Glad we could help you!
_________
Groetjes,
Joost Verdaasdonk
M.O.S. Master
Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
(I don't answer questions asked through E-mail or PM's)