English 中文(简体)
用纸质文件中的 da子替换子弹
原标题:Replace bullets with dashes in a Word document

我试图用木单替换一字文件中一个清单的子弹,基本上只有要替换的“装饰”即。

www.un.org/spanish/ecosoc 以下清单替换子弹:

  • 页: 1

  • 这是另一个项目。

  • 还有一个项目

<<>strong> with dashes:

— 页: 1

— 这是另一个项目。

— 还有一个项目

我会利用德尔菲的活性X来这样做,但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;

目前的<<><><>t>>正在检查它是否真的是一部?

如果你不需要这种检查,就应当对这一条线(if.)进行评论,并放弃下一个线......

问题回答

这是你试图做的吗?

Option Explicit

 ~~> Select the relevant range before running this code
Sub Sample()
    With ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1)
        .NumberFormat = ChrW(61485)
        .TrailingCharacter = wdTrailingTab
        .NumberStyle = wdListNumberStyleBullet
        .NumberPosition = InchesToPoints(0.25)
        .Alignment = wdListLevelAlignLeft
        .TextPosition = InchesToPoints(0.5)
        .ResetOnHigher = 0
        .StartAt = 1
        .Font.Name = "Symbol"
        .LinkedStyle = ""
    End With
    ListGalleries(wdBulletGallery).ListTemplates(1).Name = ""

    Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
    ListGalleries(wdBulletGallery).ListTemplates(1), ContinuePreviousList:= _
    False, ApplyTo:=wdListApplyToSelection, DefaultListBehavior:= _
    wdWord10ListBehavior
End Sub

<>SNAPSHOT

“entergraph

从事工作的宏观......

Dim oListTemplate As ListTemplate
Dim oListLevel As ListLevel

For Each oListTemplate In ActiveDocument.ListTemplates
    For Each oListLevel In oListTemplate.ListLevels
        If oListLevel.NumberStyle = wdListNumberStyleBullet Then
            With oListLevel
                .NumberFormat = "-"
                .Font.Name = "Arial"
            End With
        End If
    Next oListLevel
Next oListTemplate




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签