VBA: wdDialog wie zu RückgabeWerten?

Guten Tag miteinander

Ich bin dabei ein Makro zu schreiben, welches SyntaxHighlighting im Word ermöglichen soll. Klappt in den Grundzügen schon.

Um der Syntax eine Farbe zu zuweisen, will ich im Formularfeld Farbe, Font, Stil, …etc auswählen können. Dies mache ich mit Application.Dialogs(wdDialogFo­rmatDefineStyleFont). Siehe Code unten.

Mein Problem ist nun, dass ich nicht herausgefunden habe, wie ich alle Eigenschaften (Farbe, Stil, Schrift, …) zurück geben kann damit das Forumlarfeld die Eigenschaft übernimmt.

Beispiel: Wenn ich Rot, Fett, Arial auswähle soll das Textfeld im Formular die Schrift in Rot, Fett, Arial anzeigen.

Also: Wie kann ich Application.Dialogs(wdDialogFo­rmatDefineStyleFont) jede Eigenschaft übernehmen?

Grüsse
Oliver

CodeBeispiel:

Function getColor() As Integer

’ Thanks to http://www.tech-archive.net/Archive/Word/microsoft.p…

Dim MyFontDlg As Dialog
Static MyFontColor
Static MyFontStyle
Dim res

Set MyFontDlg = Application.Dialogs(wdDialogFormatDefineStyleFont)
MyFontDlg.Color = MyFontColor

res = MyFontDlg.Display

MyFontColor = MyFontDlg.Color

Debug.Print („Font Color:“ & MyFontColor)

getColor = MyFontColor

End Function

(Posting auch in microsoft.de.public.word und microsoft.public.word.vba.general)

Also: Wie kann ich
Application.Dialogs(wdDialogFo­rmatDefineStyleFont) jede
Eigenschaft übernehmen?

Hi Oliver,

hilft dir das weiter:

Option Explicit
'
Sub tt()
Dim MyFontDlg As Dialog
Application.Dialogs(wdDialogFormatDefineStyleFont).Show
Set MyFontDlg = Application.Dialogs(wdDialogFormatDefineStyleFont)
With MyFontDlg
 MsgBox .Points
 MsgBox .Underline
 MsgBox .Color

 'zur Auswahl stehen:
 'Points, Underline, Color, StrikeThrough, Superscript, Subscript, Hidden
 'SmallCaps, AllCaps, Spacing, Position, Kerning, KerningMin, Default,
 'Tab, Font, Bold, Italic, DoubleStrikeThrough, Shadow, Outline
 'Emboss, Engrave, Scale, Animations, CharAccent, FontMajor, FontLowAnsi,
 'FontHighAnsi , CharacterWidthGrid, ColorRGB, UnderlineColor, PointsBi
 'ColorBi, FontNameBi, BoldBi, ItalicBi, DiacColor

End With
End Sub

Gruß
Reinhard