为了在“文档结构图”中看到整个word文档的逻辑结构图,所以想在VC输出word的时候,设置该word文档的标题和一级目录,但是却遇到麻烦,
我在office2007中录制了宏
' 宏2 宏
'
'
Selection.Style = ActiveDocument.Styles( "标题 1 ")
Selection.MoveDown Unit:=wdLine, Count:=5
Selection.Style = ActiveDocument.Styles( "标题 2 ")
Selection.MoveDown Unit:=wdLine, Count:=5
Selection.Style = ActiveDocument.Styles( "标题 2 ")
End Sub
但是在转换成VC代码的时候发现Selection对象和Document对象都没有style方法。
同学用office2003帮我录制了以下的宏:
ActiveDocument.Styles.Add Name:= "word1 ", Type:=wdStyleTypeParagraph
ActiveDocument.Styles( "word1 ").AutomaticallyUpdate = False
With ActiveDocument.Styles( "word1 ").Font
.NameFarEast = "黑体 "
.NameAscii = "Times New Roman "
.NameOther = "Times New Roman "
.Name = "黑体 "
.Size = 16
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Scaling = 100
.Kerning = 1
.Animation = wdAnimationNone
.DisableCharacterSpaceGrid = False
.EmphasisMark = wdEmphasisMarkNone
End With