加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – 在Word文档中用短划线替换项目符号

发布时间:2020-12-15 04:12:43 所属栏目:大数据 来源:网络整理
导读:我试图用破折号替换word文档中列表的项目符号,基本上只需要替换“渲染图标”,即 从以下列表中替换项目符号: 这是一个列表项 这是另一个列表项 还有一件事 破折号: — this is a list item — this is another list item — yet another item 我将在Delphi
我试图用破折号替换word文档中列表的项目符号,基本上只需要替换“渲染图标”,即

从以下列表中替换项目符号:

>这是一个列表项
>这是另一个列表项
>还有一件事

破折号:

— this is a list item

— this is another list item

— yet another item

我将在Delphi中使用ActiveX来做这个,但VB代码也会这样做,谢谢!

解决方法

在Delphi代码中:
uses ...,ComObj;

const
  wdListNumberStyleBullet = 23;
var
  vMSWord                      : variant;
    Doc                          : Variant;
  oListTemplate                : Variant;
  oListLevel                   : Variant;
  iLoopTemplates,iMaxTemplates: Integer;
  iLoopLevels,iMaxLevels      : Integer;
begin
  try
    vMSWord         := GetActiveOleObject('Word.Application');
    vMSWord.Visible := True;
    Doc             := vMSWord.ActiveDocument;
    iMaxTemplates   := Doc.ListTemplates.Count;
    for iLoopTemplates := 1 to iMaxTemplates do
    begin
      oListTemplate := Doc.ListTemplates.Item(iLoopTemplates);
      iMaxLevels    := oListTemplate.ListLevels.Count;
      for iLoopLevels := 1 to iMaxLevels do
      begin
        oListLevel := oListTemplate.ListLevels.Item(iLoopLevels);
        if      (oListLevel.NumberStyle  = wdListNumberStyleBullet)
            and (oListLevel.NumberFormat = UTF8String(#61623))
            and (oListLevel.Font.Name    = 'Symbol') then
//        if (oListLevel.NumberStyle = wdListNumberStyleBullet) then
        begin
          oListLevel.NumberFormat := UTF8String('-');
          oListLevel.Font.Name    := 'Arial';
        end;
      end;
    end;
  except
    ShowMessage('Open a Word document before running this method');
  end;

目前的IF正在检查它是否真的是一个子弹?

如果您不需要此检查,请注释此行(如果…)并取消注释下一行…

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读