elsacarlsson
Programmer
I want to set the properties of my newly created document. I've managed to set Title, Subject and Author but I want to set Company and the "bossfield" (I've got word in Swedish so I don't know the English name for it). What are the names of the variables? To set the others I use
Wddoc.Fields.Add Range, wdFieldTitle, "Title"
Furthermore, I insert a heading with some of these fields and it should be on two rows. The top one containing author, page numbers and date. on the second row the title should be but inspite of my efforts with insertparagraph (before and after) it does not work
Set oRange = WdDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range
With oRange
.Delete
.Fields.Add oRange, wdFieldTitle
.Paragraphs.Format.LineSpacingRule = wdLineSpaceSingle
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.ParagraphFormat.SpaceAfter = 0
With .Font
.Size = 10
.Name = "Times New Roman"
.Italic = True
End With
' If DocType = "Essay" Then
.Fields.Add oRange, wdFieldDate
' ElseIf DocType = "Report" Then 'company
' .Fields.Add oRange, wdFieldsu
' End If
.InsertAfter "
" & vbTab
.Collapse wdCollapseStart
.Fields.Add oRange, wdFieldNumPages
.InsertBefore "("
.Collapse wdCollapseStart
.Fields.Add oRange, wdFieldPage
.InsertAfter vbTab
.Collapse wdCollapseStart
.Fields.Add oRange, wdFieldAuthor
end with
the last question is how do I change the paragraph format for the whole document? (adding new headings etc)
Thanks in advance
Elsa Carlsson
Wddoc.Fields.Add Range, wdFieldTitle, "Title"
Furthermore, I insert a heading with some of these fields and it should be on two rows. The top one containing author, page numbers and date. on the second row the title should be but inspite of my efforts with insertparagraph (before and after) it does not work
Set oRange = WdDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range
With oRange
.Delete
.Fields.Add oRange, wdFieldTitle
.Paragraphs.Format.LineSpacingRule = wdLineSpaceSingle
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.ParagraphFormat.SpaceAfter = 0
With .Font
.Size = 10
.Name = "Times New Roman"
.Italic = True
End With
' If DocType = "Essay" Then
.Fields.Add oRange, wdFieldDate
' ElseIf DocType = "Report" Then 'company
' .Fields.Add oRange, wdFieldsu
' End If
.InsertAfter "
.Collapse wdCollapseStart
.Fields.Add oRange, wdFieldNumPages
.InsertBefore "("
.Collapse wdCollapseStart
.Fields.Add oRange, wdFieldPage
.InsertAfter vbTab
.Collapse wdCollapseStart
.Fields.Add oRange, wdFieldAuthor
end with
the last question is how do I change the paragraph format for the whole document? (adding new headings etc)
Thanks in advance
Elsa Carlsson