![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Formularfelder sichern und wieder herstellen |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|||||||||||||||||||||
![]() |
|
![]() |
Die nachstehenden Makros aus der bereitgestellen Dokumentvorlage CHF-Formularfelder.dot zeigen, wie sich die verschiedenen Eigenschaften von Formularfeldern auslesen, sichern und
auch wiederherstellen lassen. ![]() Um die Eigenschaften der verschiedenen Formularfelder korrekt zu ermitteln, muss zuerst der Typ eines jeden Formularfeldes ermittelt werden. Da es nur drei verschiedene Formularfeldtypen gibt ( Kontrollkästchen, Textfelder und DropDown-Listenfelder. ) sich die Eigenschaften aber z.T. unterscheiden, werden nach Ermittlung des Typen alle relevanten Eigenschaften ausgelesen und in eine INI-Datei gespeichert. For Each ff In oDoc.FormFields Select Case ff.Type Case wdFieldFormTextInput fkt_ListFF strFile, "[" & ff.Name & "]" fkt_ListFF strFile, "Name", ff.Name fkt_ListFF strFile, "Type", "wdFieldFormTextInput" fkt_ListFF strFile, "Wert", ff.Result fkt_ListFF strFile, "Defaultwert", ff.TextInput.Default If oDoc.ProtectionType <> wdNoProtection Then oDoc.Unprotect fkt_ListFF strFile, "Format", ff.TextInput.Format If ff.TextInput.Type = wdCalculationText Then strType = "wdCalculationText" ElseIf ff.TextInput.Type = wdCurrentDateText Then strType = "wdCurrentDateText" ElseIf ff.TextInput.Type = wdCurrentTimeText Then strType = "wdCurrentTimeText" ElseIf ff.TextInput.Type = wdDateText Then strType = "wdDateText" ElseIf ff.TextInput.Type = wdNumberText Then strType = "wdNumberText" ElseIf ff.TextInput.Type = wdRegularText Then strType = "wdRegularText" End If fkt_ListFF strFile, "Textlänge", ff.TextInput.Width fkt_ListFF strFile, "EditType", strType oDoc.Protect wdAllowOnlyFormFields, True fkt_ListFF strFile, "CalculateOnExit", ff.CalculateOnExit fkt_ListFF strFile, "EntryMacro", ff.EntryMacro fkt_ListFF strFile, "ExitMacro", ff.ExitMacro fkt_ListFF strFile, "Enabled", ff.Enabled Case wdFieldFormCheckBox fkt_ListFF strFile, "[" & ff.Name & "]" fkt_ListFF strFile, "Name", ff.Name fkt_ListFF strFile, "Type", "wdFieldFormCheckBox" fkt_ListFF strFile, "Wert", ff.CheckBox.Value fkt_ListFF strFile, "AutoSize", ff.CheckBox.AutoSize fkt_ListFF strFile, "Size", ff.CheckBox.Size fkt_ListFF strFile, "CalculateOnExit", ff.CalculateOnExit fkt_ListFF strFile, "EntryMacro", ff.EntryMacro fkt_ListFF strFile, "ExitMacro", ff.ExitMacro fkt_ListFF strFile, "Enabled", ff.Enabled Case wdFieldFormDropDown fkt_ListFF strFile, "[" & ff.Name & "]" fkt_ListFF strFile, "Name", ff.Name fkt_ListFF strFile, "Type", "wdFieldFormDropDown" For idx = 1 To ff.DropDown.ListEntries.Count fkt_ListFF strFile, "Wert" & idx, ff.DropDown.ListEntries(idx).Name Next idx fkt_ListFF strFile, "CalculateOnExit", ff.CalculateOnExit fkt_ListFF strFile, "EntryMacro", ff.EntryMacro fkt_ListFF strFile, "ExitMacro", ff.ExitMacro fkt_ListFF strFile, "Enabled", ff.Enabled End Select Next ff Die INI-Datei besitzt anschließend folgenden Aufbau, den man über die Standard-Zugriffsmethoden (GetPrivateProfileSection) problemlos wieder auslesen kann: [Kontrollkästchen1] Name=Kontrollkästchen1 Type=wdFieldFormCheckBox Wert=Falsch AutoSize=Wahr Size=10 CalculateOnExit=Falsch EntryMacro=AktuelleSeiteDrucken ExitMacro= Enabled=Wahr [Text1] Name=Text1 Type=wdFieldFormTextInput Wert=20.05.2005 Defaultwert= Format= Textlänge=0 EditType=wdCurrentDateText CalculateOnExit=Falsch EntryMacro= ExitMacro= Enabled=Falsch [Dropdown1] Name=Dropdown1 Type=wdFieldFormDropDown Wert1=D1 Wert2=D2 Wert3=D3 CalculateOnExit=Wahr EntryMacro=Aufruf ExitMacro= Enabled=Wahr Beispiel zum Erstellen eines DropDown-Feldes aus den gespeicherten Werten: Case "wdFieldFormDropDown" Set ff = newDoc.FormFields.Add(Selection.Range, wdFieldFormDropDown) With ff j = 1 For i = LBound(strKey(), 1) To UBound(strKey(), 1) Select Case strKey(i, 0) Case "Name" ff.Name = strKey(i, 1) Case "CalculateOnExit" .CalculateOnExit = strKey(i, 1) Case "EntryMacro" .EntryMacro = strKey(i, 1) Case "ExitMacro" .ExitMacro = strKey(i, 1) Case "Enabled" bEnabled = CBool(strKey(i, 1)) Case "Wert" & j .DropDown.ListEntries.Add strKey(i, 1) j = j + 1 End Select Next i End With
|
![]() |
![]() |
Besucher: 0 online | 0 heute | 0 diesen Monat | 2264884 insgesamt | Seitenaufrufe: 131 | ![]() |
Letzte Änderung: 24.06.2006 | ![]() |
© 2001-18 Christian Freßdorf | ![]() |
Zynismus ist eine unfreundlicher Art, die Wahrheit zu sagen. Lillian Hellman, 1907-1984, amerik. Dramatikerin und Essayistin |
powered by phpCMS and PAX |