server面板上的TApplication等组件控制WORD格式菜单中的项目符号和编号 ( 积分: 100 )

  • 主题发起人 主题发起人 reegon
  • 开始时间 开始时间
R

reegon

Unregistered / Unconfirmed
GUEST, unregistred user!
下面是我录制的宏:
Sub Macro7()
'
' Macro7 Macro
' 宏在 2005-9-29 由 COMMON 录制
'
Selection.InsertBreak Type:=wdPageBreak
Selection.TypeParagraph
Selection.Style = ActiveDocument.Styles("标题 1")
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(1)
.NumberFormat = "第%1卷 "
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleSimpChinNum3
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 0
.StartAt = 1
With .Font
.Bold = True
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUnderlineNone
.Color = wdColorBlack
.Size = 18
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "黑体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(2)
.NumberFormat = "第%2章 "
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleSimpChinNum3
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 1
.StartAt = 1
With .Font
.Bold = True
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 16
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "黑体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(3)
.NumberFormat = "第%3节 "
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleSimpChinNum3
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 2
.StartAt = 1
With .Font
.Bold = True
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 15
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "黑体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(4)
.NumberFormat = "%4、 "
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleSimpChinNum3
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 3
.StartAt = 1
With .Font
.Bold = True
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 14
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "黑体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(5)
.NumberFormat = "%5. "
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 4
.StartAt = 1
With .Font
.Bold = False
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 12
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "黑体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(6)
.NumberFormat = ""
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleNone
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 5
.StartAt = 1
With .Font
.Bold = False
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 12
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "宋体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(7)
.NumberFormat = ""
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleNone
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 6
.StartAt = 1
With .Font
.Bold = False
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 12
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "宋体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(8)
.NumberFormat = ""
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleNone
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 7
.StartAt = 1
With .Font
.Bold = False
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 12
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "宋体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(9)
.NumberFormat = "%9. "
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 8
.StartAt = 1
With .Font
.Bold = False
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 12
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "宋体"
End With
.LinkedStyle = ""
End With
ListGalleries(wdOutlineNumberGallery).ListTemplates(6).Name = ""
Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _
wdOutlineNumberGallery).ListTemplates(6), ContinuePreviousList:=False, _
ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:=wdWord9ListBehavior
Selection.TypeText Text:="AAA"
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.TypeParagraph
Selection.TypeText Text:="asdffg"
End Sub
如何用server面板上的组件实现,把上面的宏代码转成delphi程序代码,请大家帮忙看看,急!因
 
下面是我录制的宏:
Sub Macro7()
'
' Macro7 Macro
' 宏在 2005-9-29 由 COMMON 录制
'
Selection.InsertBreak Type:=wdPageBreak
Selection.TypeParagraph
Selection.Style = ActiveDocument.Styles("标题 1")
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(1)
.NumberFormat = "第%1卷 "
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleSimpChinNum3
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 0
.StartAt = 1
With .Font
.Bold = True
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUnderlineNone
.Color = wdColorBlack
.Size = 18
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "黑体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(2)
.NumberFormat = "第%2章 "
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleSimpChinNum3
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 1
.StartAt = 1
With .Font
.Bold = True
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 16
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "黑体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(3)
.NumberFormat = "第%3节 "
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleSimpChinNum3
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 2
.StartAt = 1
With .Font
.Bold = True
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 15
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "黑体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(4)
.NumberFormat = "%4、 "
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleSimpChinNum3
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 3
.StartAt = 1
With .Font
.Bold = True
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 14
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "黑体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(5)
.NumberFormat = "%5. "
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 4
.StartAt = 1
With .Font
.Bold = False
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 12
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "黑体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(6)
.NumberFormat = ""
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleNone
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 5
.StartAt = 1
With .Font
.Bold = False
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 12
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "宋体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(7)
.NumberFormat = ""
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleNone
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 6
.StartAt = 1
With .Font
.Bold = False
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 12
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "宋体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(8)
.NumberFormat = ""
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleNone
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 7
.StartAt = 1
With .Font
.Bold = False
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 12
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "宋体"
End With
.LinkedStyle = ""
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(6).ListLevels(9)
.NumberFormat = "%9. "
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 8
.StartAt = 1
With .Font
.Bold = False
.Italic = False
.StrikeThrough = False
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdColorBlack
.Size = 12
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "宋体"
End With
.LinkedStyle = ""
End With
ListGalleries(wdOutlineNumberGallery).ListTemplates(6).Name = ""
Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _
wdOutlineNumberGallery).ListTemplates(6), ContinuePreviousList:=False, _
ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:=wdWord9ListBehavior
Selection.TypeText Text:="AAA"
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.TypeParagraph
Selection.TypeText Text:="asdffg"
End Sub
如何用server面板上的组件实现,把上面的宏代码转成delphi程序代码,请大家帮忙看看,急!因
 
项目符号和编号在word中处理有点怪,要注意ListGalleries、ListTemplates、ListLevels三个对象,比较麻烦,去看看word的VBA帮助,把概念搞清楚了就好办了,相信你能搞定的。
 
是的,ListGalleries、ListTemplates、ListLevels三个对象是很难搞定,我在WORD中录制的宏代码,根本就无法转成delphi代码,我用的是server面板上的wordapplication等控件
是关于这个项目符号和编号在word中设定,我的程序是这样的,我用的DBTREE控件,
节点一1(标题)
节点二1 (下一级标题)
节点三1 (文档内容)
节点三2 (文档内容)
节点一2
........
我想把它传到WORD中,并生成文档,其中,在标题节点在word里要加项目符号和编号,同时生成目录如:
第一章 节点一1......................................2
第一节 XXX......................................3
第二章 节点一2.....................................5
......
不知大家有没有理解我的意思,请大家帮忙看看
 
ListGalleries有三个(对应项目符号、编号、多级符号),ListTemplates有七个(对应面板上的七个框),ListLevels不记得有几项了(功能是指定框里的属性,你要在这里指定各属性),你设置的时候要三个都指定的。
 
你好,newsmile,能给我一个例子让我参考一下吗,好吗
 
我是用ole控制word的,和你的不一样,我从来没有用过server面板上的控件。虽然控制原理一样但代码相差太大,可能我的代码对你来说没有什么参考价值吧
 
newsmile,你好,我也是用OLEContainer来控制WORD,刚开始就是用它,不过搞到后来,特别是索引和目录那方面,总是出错,我后来才改用server面板上的WordApplication
如果能用OLEContainer控制WORD实现,那就最好了
能发些OLEContainer控制WORD的例程吗,先谢谢了!
 
newsmile,你好,我的QQ:38634500
Email:reegon@163.com
我很希望能和你多交流,我现在正在做一个标书管理的软件,如果你方便的话,我把我做的发给你指点一下,可以吗?
 
我用ole不用OLEContainer,我的代码在家里,明天拿段给你参考。我没有QQ。你做标书管理应该用模板,那样比较好些,本论坛有相关的代码,你查一下旧贴应该可以查到(如果你有离线数据库很好查的)。
 
好的,谢谢newsmile,明天给一些OLE控制WORD的设置标题的项目符号和编号的代码,以有定位到文档首页插入索引目录的代码,好吗,太感谢了!
标书素材我这里有素材库,我用的ACCESS作数据库
你所说的用模板,是什么意思啊!应该套用什么样的模板呢?
 
word模板,操纵模板要简单很多。本论坛旧贴里有例子。
 
我现在没用模板,我是每次打开一个空的WORD,然后插入我的工程标书!
我用的是DBTREE控件,树结构如下:
XX标书
工业厂房 -->这是一个标题 1(字段类型为 文本字符类型)
钢柱XX -->这是工业厂房下的一个文档(OLE字段)
......
XXX厂房 -->工业厂房下的一个子标题,(字段类型为 文本字符类型)
屋面防水 -> 文档内容(OLE字段)
给水排水 -->这是一个标题 2 (字段类型为 文本字符类型)
水厂改造 -->这是内容文档(OLE字段)
......
我简单的用以上形式来表示,现在我在生成标书时,我已经能够把工程库中的素材文档全部转入WORD中;
但在转入word 时,首先从工业厂房开始,它是标题,在WORD中直接TYPETEXT标题文字,居中即可,不过我还要在标题前,加上比如说'第一章'这类字, 也就是'第一章 工业厂房',换行后是它的子标题(第一节 XXXX),或者是文档内容.
到第二个同级的标题'给水排水',即'第二章 给水排水';其下一级标题就为'第一节 XXXX',
请问NEWSMILE能明白我的意思吧,很感谢你的指点,我想知道你以前是用什么方法实现它这个多级符号的!
 
给你发了邮件,查收。有问题再联系。
 
好的,谢谢你,NEWSMILE,我马上去看看!
 
NEWSMILE,我把我的代码发到你邮箱里了,请你看看好吗
附件里有一个word 文件,你看看它里面目录的样式,以及那个多级编号的标题,如第一章,第一节等!
 
到现在还没有收到不知怎么回事?
 
我这边是成功发送出去了的,我再发一次看看!
 
收到了。
 
NEWSMILE,你看了后,能否提点一下,你觉得那个设置标题的项目符号和编号,也就是我想用多级编号的那一块应该如何处理.....
 
后退
顶部