Any expert knows:
1) How to set WordDocument selection's font color? I tried
Doc.Application.Selection.Font.ColorIndex := clRed. It would not work. I
can not find a Font.Color property in Word97.
2) Also how to automate selection format with Bullets/Numberings?
There is no this property in paragraphs.
Thanks.
James
You need to read the Word VBA Help Files:
WdColorIndex can be one of these WdColorIndex constants.
wdAuto
wdBlack
wdBlue
wdBrightGreen
wdByAuthor
wdDarkBlue
wdDarkRed
wdDarkYellow
wdGray25
wdGray50
wdGreen
wdNoHighlight
wdPink
wdRed
wdTeal
wdTurquoise
wdViolet
wdWhite
wdYellow
> 2) Also how to automate selection format with Bullets/Numberings?
> There is no this property in paragraphs.
No, its a property of a Range. The simplest way to find out what you need
to automate is to record a macro that does what you want and look at the
subsequent VBA code. If you did, you would see something like:
With ListGalleries(wdNumberGallery).ListTemplates(1).ListLevels(1)
.NumberFormat = "%1."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = CentimetersToPoints(0.63)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(1.27)
.TabPosition = CentimetersToPoints(1.27)
.ResetOnHigher = 0
.StartAt = 1
With .Font
.Bold = wdUndefined
.Italic = wdUndefined
.StrikeThrough = wdUndefined
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdUndefined
.Size = wdUndefined
.Animation = wdUndefined
.DoubleStrikeThrough = wdUndefined
.Name = ""
End With
.LinkedStyle = ""
End With
ListGalleries(wdNumberGallery).ListTemplates(1).Name = ""
Selection.Range.ListFormat.ApplyListTemplate
ListTemplate:=ListGalleries( _
wdNumberGallery).ListTemplates(1), ContinuePreviousList:=False,
ApplyTo:= _
wdListApplyToWholeList, DefaultListBehavior:=wdWord10ListBehavior
Oliver Townshend
Range.ListFormat.ApplyBulletDefault;
but failed at importing recorded Macro -- I can not find a Delphi
equivalent of ChrW function for:
NumberFormat := ChrW(61607)
James.
"Oliver Townshend" <oliver_at_zip_com_au> wrote in message
news:40de...@newsgroups.borland.com...
Go in to VBA Editor inside Word, pull up the Instant window and type
?Chrw(61607) which will tell you the value of that function.
Oliver Townshend
VBA gave out a question mark '?' for ChrW(61607). I think this usually
means non-printable character. I plug this in Delphi. It generates very
funny looking bullets. On the better end, it no longer causes "out of
range" error.
James
"Oliver Townshend" <oliver_at_zip_com_au> wrote in message
news:40de...@newsgroups.borland.com...
procedure TForm1.btnBulletsClick(Sender: TObject);
var
vListTemplate: ListTemplate;
vLevel: OleVariant;
OutlineNum: OleVariant;
Level: ListLevel;
ContinuePrev: OleVariant;
begin
WordDocument1.Select;
WordDocument1.Application.Selection.TypeText('a');
WordDocument1.Application.Selection.TypeParagraph;
WordDocument1.Application.Selection.TypeText('b');
WordDocument1.Application.ActiveDocument.Select;
OutLineNum := True;
vListTemplate := WordDocument1.ListTemplates.Add(OutLineNum, EmptyParam);
Level := vListTemplate.ListLevels.Item(1);
Level.NumberFormat := '?'; //ChrW(61607);
Level.TrailingCharacter := wdTrailingTab;
Level.NumberStyle := wdListNumberStyleBullet;
Level.Alignment := wdListLevelAlignLeft;
Level.Font.Bold := wdUndefined;
Level.Font.Italic := wdUndefined;
Level.Font.StrikeThrough := wdUndefined;
Level.Font.Subscript := wdUndefined;
Level.Font.Superscript := wdUndefined;
Level.Font.Shadow := wdUndefined;
Level.Font.Outline := wdUndefined;
Level.Font.Emboss := wdUndefined;
Level.Font.Engrave := wdUndefined;
Level.Font.AllCaps := wdUndefined;
Level.Font.Hidden := wdUndefined;
Level.Font.Underline := wdUndefined;
Level.Font.ColorIndex := wdUndefined;
Level.Font.Size := 10;
Level.Font.Animation := wdUndefined;
Level.Font.DoubleStrikeThrough := wdUndefined;
Level.Font.Name := 'Wingdings';
Level.LinkedStyle := '';
ContinuePrev := False;
WordDocument1.Range.ListFormat.ApplyListTemplate(vListTemplate,
ContinuePrev, EmptyParam); //wdListApplyToWholeList);
end;
"James" <NoSpamJ...@sympatico.ca> wrote in message
Looking in the help file is see that ChrW is a Character Wide function. So
there should be an equivalent in Delphi (although I can't find it). I'm
surprised Word 97 cares about this. Did you work from my code? Because I
ran Word 2003 to generate the code. Maybe you should run Word 97 and check
what it generates.
Oliver Townshend
I generated the code from Word 97 with the macro recording method you
suggested. And then removed a few of those properties causing error in
Delphi. Word seems to like to use those strange characters (rather than
image), for the speed purpose I guess. Other than the look of bullet
itself. The code does work though.
Also do you (or anyone else) happen to know a Word color picker
component?
Thanks again.
Wanli
"Oliver Townshend" <oliver_at_zip_com_au> wrote in message
news:40de...@newsgroups.borland.com...
There's one on the toolbar. Are you automating inside or outside of Word?
Oliver Townshend
procedure TForm1.Button1Click(Sender: TObject);
var
ListFmt: ListFormat;
ContinueList: OleVariant;
begin
ListFmt := WordDocument1.Application.Selection.Range.ListFormat;
ListFmt.ApplyBulletDefault;
ContinueList := False;
ListFmt.ApplyListTemplate(ListFmt.ListTemplate, ContinueList, EmptyParam);
end;
James
"Oliver Townshend" <oliver_at_zip_com_au> wrote in message
news:40de...@newsgroups.borland.com...
"Oliver Townshend" <oliver_at_zip_com_au> wrote in message
news:40de...@newsgroups.borland.com...
I can't really help you then, most of my work is in VBA macros and Delphi
Add-ins.
Oliver Townshend
I also do some Office automation in pure VB. But I more like automation
with Delphi via either OLE container or WebBrowser. There is less
security/virus issue for one. There are disadvantages though: OLE
container menu merge is a mess. Yet with WebBrowser, all menu/tool bars are
lost.
James
"Oliver Townshend" <oliver_at_zip_com_au> wrote in message
news:40de...@newsgroups.borland.com...