微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我试图用破折号替换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正在检查它是否真的是一个子弹•

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

原文地址:https://www.jb51.cc/delphi/102040.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐