AW: Format - VBA
18.06.2007 23:13:00
Daniel
Hi
wirf doch einfach mal den Recorder an, dann siehst du, wie sowas geht:
Sub test()
Range("A1").Select
ActiveCell.FormulaR1C1 = "Dr. Karl Thomas"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Arial"
.FontStyle = "Fett"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=5, Length:=4).Font
.Name = "Arial"
.FontStyle = "Kursiv"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=9, Length:=7).Font
.Name = "Arial"
.FontStyle = "Standard"
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B1").Select
End Sub
die Start- und Längenwerte für die einzelnen Abschitte kannst du dir dann mit der VBA-Funktion:
LEN(textbox1.value) jeweils berechnen, z.b. dann so:
With ActiveCell.Characters(Start:=len(texbox1.text)+len(textbox2.text)+1, Length:=len(textbox3.text)).Font
Gruß, Daniel
ps, du mußt nicht immer alle Formate angeben, es reichen diejenigen, die du verändern willst, bzw. die vom Standardwert abweichen.