Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Manipulating Word from vb

Status
Not open for further replies.

elsacarlsson

Programmer
Jul 23, 2002
6
SE
I want to set the properties of my newly created word 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top