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正在检查它是否真的是一个子弹•

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

相关文章

 从网上看到《Delphi API HOOK完全说明》这篇文章,基本上都...
  从网上看到《Delphi API HOOK完全说明》这篇文章,基本上...
ffmpeg 是一套强大的开源的多媒体库 一般都是用 c/c+&#x...
32位CPU所含有的寄存器有:4个数据寄存器(EAX、EBX、ECX和ED...
1 mov dst, src dst是目的操作数,src是源操作数,指令实现的...