Klasse TextInput (Word VBA)

Die Klasse TextInput stellt ein einzelnes Textformularfeld dar. Um eine TextInput -Klassenvariable zu verwenden, muss sie zuerst instanziert werden, beispielsweise


Dim tit as TextInput
Set tit = ActiveDocument.FormFields(1).TextInput

Clear

Löscht den Text aus dem angegebenen Textformularfeld.


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True 
If ActiveDocument.FormFields(1).Type = wdFieldFormTextInput Then 
 ActiveDocument.FormFields(1).TextInput.Clear 
End If

Default

Gibt den Text zurück, der den standardmäßigen Textfeldinhalt darstellt, oder legt diesen Text fest.


ActiveDocument.FormFields(1).TextInput.Default =

EditType

Legt Optionen für das angegebene Textformularfeld fest.

EditType (Type, Default, Format, Enabled)


With ActiveDocument.FormFields.Add _ 
 (Range:=ActiveDocument.Range(0, 0), _ 
 Type:=wdFieldFormTextInput) 
 .Name = "Today" 
 .TextInput.EditType Type:=wdCurrentDateText, _ 
 Format:="M/d/yy", Enabled:=False 
End With

Arguments

Ein benanntes Argument

Type - WdTextFormFieldType


Möglichen Werte sind

wdCalculationText Berechnung.
wdCurrentDateText Aktuelles Datum.
wdCurrentTimeText Aktuelle Uhrzeit.
wdDateText Datum.
wdNumberText Zahl.
wdRegularText Normales Textfeld.

Optional arguments

Die folgenden Argumente sind optional

Default (String) - Der Standardtext, der im Textfeld angezeigt wird.

Format (String) - Die Formatierungszeichenfolge, die zum Formatieren des Texts, der Zahl oder des Datums verwendet wird (z. B. "0,00", "Erster Buchstabe groß" oder "M/T/JJ").

Enabled (Boolean) - True, um das Formularfeld für Texteingabe zu aktivieren.

Format

Gibt die Textformatierung für das angegebene Textfeld zurück.


If ActiveDocument.FormFields(1).Type = wdFieldFormTextInput Then 
 MsgBox ActiveDocument.FormFields(1).TextInput.Format 
Else 
 MsgBox "First field is not a text form field" 
End If

Type

Gibt den Typ des Textformularfelds zurück. Mögliche Rückgabewerte sind wdCalculationText - Berechnung, wdCurrentDateText - Aktuelles Datum, wdCurrentTimeText - Aktuelle Uhrzeit, wdDateText - Datum, wdNumberText - Zahl, wdRegularText - Normales Textfeld.


Dim wtfType As WdTextFormFieldType
wtfType = ActiveDocument.FormFields(1).TextInput.Type

Valid

True, wenn es sich bei dem angegebenen Formularfeldobjekt um ein zulässiges Kontrollkästchen-Formularfeld handelt.


If ActiveDocument.FormFields(1).TextInput.Valid = True Then 
 ActiveDocument.FormFields(1).Result = "Hello" 
End If

Width

Gibt die Breite des angegebenen Texteingabefelds in Punktzurück oder legt Sie fest.


ActiveDocument.FormFields(1).TextInput.Width =