Hi,
I am using VBA to open a new Word document from another aplication.
I am allso adding some text, and I want to change font, bold, italic, alignment and so on.
I can change the font-name and -size but not if it Bold or the alignemnt. I am also trying to underline a row and add a table, but I can bet i to work.
Maybe it cant be done from the program I am in?
//Anders Olsson
I am using VBA to open a new Word document from another aplication.
I am allso adding some text, and I want to change font, bold, italic, alignment and so on.
I can change the font-name and -size but not if it Bold or the alignemnt. I am also trying to underline a row and add a table, but I can bet i to work.
Code:
Set wdApp = CreateObject("Word.Application")
'Add a document.
Set wdDoc = wdApp.Documents.Add
wdApp.Visible = True
wdApp.Selection.Font.size = 16 'this works
wdApp.Selection.Font.Name = "Arial"
wdApp.Selection.Font.Name = "Arial" 'this works
wdApp.Font.Bold = wdToggle 'this dosent work
wdApp.Selection.ParagraphFormat.Alignment = _ wdAlignParagraphCenter 'this dosent work
'This doesn't work
wdApp.Selection.Borders(wdBorderBottom).LineStyle = Options.DefaultBorderLineStyle
wdApp.Selection.Borders(wdBorderBottom).LineWidth = Options.DefaultBorderLineWidth
wdApp.Selection.Borders(wdBorderBottom).Color = Options.DefaultBorderColor
'this doesnt work
wdApp.ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _
4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
Maybe it cant be done from the program I am in?
//Anders Olsson