Guten Tag liebe VB Community.
Ich bin neu in diesem Forum und auch was die VB(A) programmierung angeht noch sehr laienhaft.
Ich hoffe das mir hier geholfen werden kann. Das würde mich außerordentlich freuen.
Zu meinem Problem.
Ich habe ein Formular in MS Word erstellt mit Pflichtfeldern, DropDown Menüs usw.
Wie bereits erwähnt habe ich mit Hilfe von VBA einige dieser Formularfelder zu Pflichtfeldern gemacht.
Vor jedem Speichervorgang prüft das Script ob alle notwendigen Felder ausgefüllt sind und beanstandet dieses falls nötig.
Nun sollen einige dieser Felder ausgelesen werden und deren Inhalt soll an eine Excel Tabelle übergeben werden.
Den dafür nötigen Code habe ich ebenfalls bereits erstellt und er funktioniert auch soweit.
Jedoch habe ich ein paar Probleme mit denen ich etwas Hilfe gebrauchen könnte.
1.
Wenn Word die Daten an Excel übergibt, dann schreibt Excel diese immer in die selbe Zeile obwohl ich meiner Meinung nach deklariert habe dafür immer eine neue Zeile zu verwenden.
Frage:
Gibt es eine Möglichkeit Excel zu sagen, Prüfe Zeile XY wenn Zeile XY bereits belegt, dann gehe eine Zeile darunter und trage dort die Daten ein. Zeile ebenfalls belegt? Dann gehe eine Zeile weiter bis du eine leere Zeile findest.
2.
Ich hätte ganz gerne vermieden, da dieses Formular von Leuten ausgefüllt wird die so rein gar keine Ahnung von VBA und dem Editor haben, das diese das Script von Hand ausführen müssen.
Frage:
Wie stelle ich es an, das Word diesen Teil Des Scripts ebenfalls vor einem Speichervorgang ausführt, allerdings nachdem die Pflichtfelder das Script auf völlständigkeit geprüft haben jedoch vor dem eigentlich Speichervorgang. Ich hoffe ich habe das verständlich genug beschrieben.
Das war erstmal alles.
Hier ist der Code für das Script.
Dieser Teil befindet sich direkt in ThisDocument:
Der Zweite Teil welcher die Daten an Excel übertragen soll befindet sich in einem extra Modul Namens Word2Excel.
Ich hoffe das mir hier jemand helfen kann.
Fürs anschauen vielen Dank im Voraus.
Ich bin neu in diesem Forum und auch was die VB(A) programmierung angeht noch sehr laienhaft.
Ich hoffe das mir hier geholfen werden kann. Das würde mich außerordentlich freuen.
Zu meinem Problem.
Ich habe ein Formular in MS Word erstellt mit Pflichtfeldern, DropDown Menüs usw.
Wie bereits erwähnt habe ich mit Hilfe von VBA einige dieser Formularfelder zu Pflichtfeldern gemacht.
Vor jedem Speichervorgang prüft das Script ob alle notwendigen Felder ausgefüllt sind und beanstandet dieses falls nötig.
Nun sollen einige dieser Felder ausgelesen werden und deren Inhalt soll an eine Excel Tabelle übergeben werden.
Den dafür nötigen Code habe ich ebenfalls bereits erstellt und er funktioniert auch soweit.
Jedoch habe ich ein paar Probleme mit denen ich etwas Hilfe gebrauchen könnte.
1.
Wenn Word die Daten an Excel übergibt, dann schreibt Excel diese immer in die selbe Zeile obwohl ich meiner Meinung nach deklariert habe dafür immer eine neue Zeile zu verwenden.
Frage:
Gibt es eine Möglichkeit Excel zu sagen, Prüfe Zeile XY wenn Zeile XY bereits belegt, dann gehe eine Zeile darunter und trage dort die Daten ein. Zeile ebenfalls belegt? Dann gehe eine Zeile weiter bis du eine leere Zeile findest.
2.
Ich hätte ganz gerne vermieden, da dieses Formular von Leuten ausgefüllt wird die so rein gar keine Ahnung von VBA und dem Editor haben, das diese das Script von Hand ausführen müssen.
Frage:
Wie stelle ich es an, das Word diesen Teil Des Scripts ebenfalls vor einem Speichervorgang ausführt, allerdings nachdem die Pflichtfelder das Script auf völlständigkeit geprüft haben jedoch vor dem eigentlich Speichervorgang. Ich hoffe ich habe das verständlich genug beschrieben.
Das war erstmal alles.
Hier ist der Code für das Script.
Dieser Teil befindet sich direkt in ThisDocument:
Quellcode
- Private Sub Document_Open()
- End Sub
- Sub FilePrintDefault()
- If Checkfields = True Then ActiveDocument.PrintOut
- End Sub
- Sub FilePrint()
- FilePrintDefault
- End Sub
- Sub FileSave()
- If Checkfields = True Then
- If ActiveDocument.Path = "" Then
- FileSaveAs
- End If
- ActiveDocument.Save
- End If
- End Sub
- Sub FileSaveAs()
- If Checkfields = True Then
- Dialogs(wdDialogFileSaveAs).Show
- End If
- End Sub
- Private Sub ComboBox1_DropDownClick()
- ComboBox1.List = Array(" ", "Armatur funktionssicher instandgesetzt.", "Weitere Maßnahmen erforderlich. (siehe Text)", "Wartung nicht möglich. (siehe Text)")
- End Sub
- Private Sub ComboBox1_Change()
- If ComboBox1.Text = " " Then
- ComboBox1.BackColor = RGB(224, 224, 224)
- ActiveDocument.FormFields("Hinweise").Result = ""
- O4A.Enabled = True
- O4B.Enabled = True
- End If
- If ComboBox1.Text = "Armatur funktionssicher instandgesetzt." Then
- ComboBox1.BackColor = RGB(34, 139, 34)
- O4A.Enabled = True
- O4B.Enabled = True
- End If
- If ComboBox1.Text = "Weitere Maßnahmen erforderlich. (siehe Text)" Then
- ComboBox1.BackColor = RGB(255, 255, 0)
- End If
- If ComboBox1.Text = "Wartung nicht möglich. (siehe Text)" Then
- ComboBox1.BackColor = RGB(255, 0, 0)
- End If
- End Sub
- Private Function Checkfields() As Boolean
- If ActiveDocument.FormFields("Hersteller").Result = " " Then
- MsgBox "Bitte Hersteller auswählen!"
- Checkfields = False
- ActiveDocument.FormFields("Hersteller").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("EquiNr").Result = "" Then
- MsgBox "Bitte Equipment-Nr. eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("EquiNr").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("Typ").Result = "" Then
- MsgBox "Bitte Typ eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("Hinweise").Result = ""
- ActiveDocument.FormFields("Typ").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("Typ").Result = "EH/Z" Then
- MsgBox "ACHTUNG!" & vbCrLf & "" & vbCrLf & "Zulassung zurückgezogen!" & vbCrLf & _
- "System wird auf 'Rot' gesetzt."
- Checkfields = False
- ComboBox1 = "Weitere Maßnahmen erforderlich. (siehe Text)"
- ComboBox1.BackColor = RGB(255, 0, 0)
- ActiveDocument.FormFields("Hinweise").Result = _
- "Für dieses System wurde 1989 die Zulassung zurückgezogen. Wir empfehlen ausdrücklich den Austausch gegen ein System nach dem aktuellen Stand der Technik - ATEX (EN 12874/ISO 16852)."
- Exit Function
- End If
- If ActiveDocument.FormFields("Typ").Result = "EH/K" Then
- MsgBox "ACHTUNG!" & vbCrLf & "" & vbCrLf & "Zulassung zurückgezogen!" & vbCrLf & _
- "System wird auf 'Rot' gesetzt."
- Checkfields = False
- ComboBox1 = "Weitere Maßnahmen erforderlich. (siehe Text)"
- ComboBox1.BackColor = RGB(255, 0, 0)
- ActiveDocument.FormFields("Hinweise").Result = _
- "Für dieses System wurde 1989 die Zulassung zurückgezogen. Wir empfehlen ausdrücklich den Austausch gegen ein System nach dem aktuellen Stand der Technik - ATEX (EN 12874/ISO 16852)."
- Exit Function
- End If
- If ActiveDocument.FormFields("Typ").Result = "SD/BK" Then
- MsgBox "ACHTUNG!" & vbCrLf & "" & vbCrLf & "Zulassung zurückgezogen!" & vbCrLf & _
- "System wird auf 'Rot' gesetzt."
- Checkfields = False
- ComboBox1 = "Weitere Maßnahmen erforderlich. (siehe Text)"
- ComboBox1.BackColor = RGB(255, 0, 0)
- ActiveDocument.FormFields("Hinweise").Result = _
- "Für dieses System wurde 1989 die Zulassung zurückgezogen. Wir empfehlen ausdrücklich den Austausch gegen ein System nach dem aktuellen Stand der Technik - ATEX (EN 12874/ISO 16852)."
- Exit Function
- End If
- If ActiveDocument.FormFields("Typ").Result = "VD/BK" Then
- MsgBox "ACHTUNG!" & vbCrLf & "" & vbCrLf & "Zulassung zurückgezogen!" & vbCrLf & _
- "System wird auf 'Rot' gesetzt."
- Checkfields = False
- ComboBox1 = "Weitere Maßnahmen erforderlich. (siehe Text)"
- ComboBox1.BackColor = RGB(255, 0, 0)
- ActiveDocument.FormFields("Hinweise").Result = _
- "Für dieses System wurde 1989 die Zulassung zurückgezogen. Wir empfehlen ausdrücklich den Austausch gegen ein System nach dem aktuellen Stand der Technik - ATEX (EN 12874/ISO 16852)."
- Exit Function
- End If
- If ActiveDocument.FormFields("Typ").Result = "UB/LH" Then
- MsgBox "ACHTUNG!" & vbCrLf & "" & vbCrLf & "Zulassung eingeschränkt!" & vbCrLf & _
- "System bleibt auf 'Grün', sofern keine Mängel vorhanden."
- Checkfields = False
- ComboBox1 = "Weitere Maßnahmen erforderlich. (siehe Text)"
- ComboBox1.BackColor = RGB(34, 139, 34)
- ActiveDocument.FormFields("Hinweise").Result = _
- "Die betroffenen Altarmaturen entsprechen seit 1989 nicht mehr dem Stand der Technik. Wir empfehlen ausdrücklich den Austausch!"
- Exit Function
- End If
- If ActiveDocument.FormFields("Typ").Result = "UB/D" Then
- MsgBox "ACHTUNG!" & vbCrLf & "" & vbCrLf & "Zulassung eingeschränkt!" & vbCrLf & _
- "System bleibt auf 'Grün', sofern keine Mängel vorhanden."
- Checkfields = False
- ComboBox1 = "Weitere Maßnahmen erforderlich. (siehe Text)"
- ComboBox1.BackColor = RGB(34, 139, 34)
- ActiveDocument.FormFields("Hinweise").Result = _
- "Die betroffenen Altarmaturen entsprechen seit 1989 nicht mehr dem Stand der Technik. Wir empfehlen ausdrücklich den Austausch!"
- Exit Function
- End If
- If ActiveDocument.FormFields("Typ").Result = "UB/DV" Then
- MsgBox "ACHTUNG!" & vbCrLf & "" & vbCrLf & "Zulassung eingeschränkt!" & vbCrLf & _
- "System bleibt auf 'Grün', sofern keine Mängel vorhanden."
- Checkfields = False
- ComboBox1 = "Weitere Maßnahmen erforderlich. (siehe Text)"
- ComboBox1.BackColor = RGB(34, 139, 34)
- ActiveDocument.FormFields("Hinweise").Result = _
- "Die betroffenen Altarmaturen entsprechen seit 1989 nicht mehr dem Stand der Technik. Wir empfehlen ausdrücklich den Austausch!"
- Exit Function
- End If
- If ActiveDocument.FormFields("NW").Result = "" Then
- MsgBox "Bitte Nennweite eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("NW").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PTB").Result = "" Then
- MsgBox "Bitte PTB/ATEX Nr. eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PTB").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("SNR").Result = "" Then
- MsgBox "Bitte Seriennummer eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("SNR").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("GWRKST").Result = " " Then
- MsgBox "Bitte Gehäusewerkstoff auswählen!"
- Checkfields = False
- ActiveDocument.FormFields("GWRKST").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("GDTNG").Result = " " Then
- MsgBox "Bitte Gehäusedichtung auswählen!"
- Checkfields = False
- ActiveDocument.FormFields("GDTNG").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("MWRKST").Result = " " Then
- MsgBox "Bitte Membranwerkstoff auswählen!"
- Checkfields = False
- ActiveDocument.FormFields("MWRKST").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("MED").Result = " " Then
- MsgBox "Bitte Belastungsmedium auswählen!"
- Checkfields = False
- ActiveDocument.FormFields("MED").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PMBAR").Result = "" Then
- MsgBox "Bitte Einstellüberdruck eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PMBAR").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PVWRKST").Result = " " Then
- MsgBox "Bitte Überdruck Ventilteller-Werkstoff auswählen!"
- Checkfields = False
- ActiveDocument.FormFields("PVWRKST").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PVDTNG").Result = " " Then
- MsgBox "Bitte Überdruck Ventilteller-Dichtung auswählen!"
- Checkfields = False
- ActiveDocument.FormFields("PVDTNG").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("VMBAR").Result = "" Then
- MsgBox "Bitte Einstellunterdruck eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("VMBAR").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("VVWRKST").Result = " " Then
- MsgBox "Bitte Unterdruck Ventilteller-Werkstoff auswählen!"
- Checkfields = False
- ActiveDocument.FormFields("VVWRKST").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("VVDTNG").Result = " " Then
- MsgBox "Bitte Unterdruck Ventilteller-Dichtung auswählen!"
- Checkfields = False
- ActiveDocument.FormFields("VMBAR").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("FFA").Enabled = True And ActiveDocument.FormFields("FFA").Result = "" Then
- MsgBox "Bitte die Anzahl Filterscheiben eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("FFA").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("SW").Enabled = True And ActiveDocument.FormFields("SW").Result = "" Then
- MsgBox "Bitte die Spaltweite eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("SW").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("WR").Enabled = True And ActiveDocument.FormFields("WR").Result = " " Then
- MsgBox "Bitte die Wickelrichtung auswählen!"
- Checkfields = False
- ActiveDocument.FormFields("WR").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("FFWRKST").Enabled = True And ActiveDocument.FormFields("FFWRKST").Result = " " Then
- MsgBox "Bitte den Flammenfilter-Werkstoff auswählen!"
- Checkfields = False
- ActiveDocument.FormFields("FFWRKST").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("FKWRKST").Enabled = True And ActiveDocument.FormFields("FKWRKST").Result = " " Then
- MsgBox "Bitte den Filterkäfig-Werkstoff auswählen!"
- Checkfields = False
- ActiveDocument.FormFields("FKWRKST").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("ZWL").Enabled = True And ActiveDocument.FormFields("ZWL").Result = "" Then
- MsgBox "Bitte die Anzahl der Zwischenlagen eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("ZWL").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PEPP").Enabled = True And ActiveDocument.FormFields("PEPP").Result = "" Then
- MsgBox "Bitte die Überdruck mbar eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PEPP").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PEPT").Enabled = True And ActiveDocument.FormFields("PEPT").Result = "" Then
- MsgBox "Bitte die Überdruck Prüfdauer eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PEPT").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PEPZ").Enabled = True And ActiveDocument.FormFields("PEPZ").Result = "" Then
- MsgBox "Bitte die Überdruck Prüfzyklen eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PEPZ").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PEVP").Enabled = True And ActiveDocument.FormFields("PEVP").Result = "" Then
- MsgBox "Bitte die Unterdruck mbar eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PEVP").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PEVT").Enabled = True And ActiveDocument.FormFields("PEVT").Result = "" Then
- MsgBox "Bitte die Unterdruck Prüfdauer eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PEVT").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PEVZ").Enabled = True And ActiveDocument.FormFields("PEVZ").Result = "" Then
- MsgBox "Bitte die Unterdruck Prüfzyklen eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PEVZ").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PEN").Enabled = True And ActiveDocument.FormFields("PEN").Result = "" Then
- MsgBox "Bitte Name des Prüfers eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PEN").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PPPP").Enabled = True And ActiveDocument.FormFields("PPPP").Result = "" Then
- MsgBox "Bitte die Überdruck mbar eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PPPP").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PPPT").Enabled = True And ActiveDocument.FormFields("PPPT").Result = "" Then
- MsgBox "Bitte die Überdruck Prüfdauer eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PPPT").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PPPZ").Enabled = True And ActiveDocument.FormFields("PPPZ").Result = "" Then
- MsgBox "Bitte die Überdruck Prüfzyklen eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PPPZ").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PPVP").Enabled = True And ActiveDocument.FormFields("PPVP").Result = "" Then
- MsgBox "Bitte die Unterdruck mbar eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PPVP").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PPVT").Enabled = True And ActiveDocument.FormFields("PPVT").Result = "" Then
- MsgBox "Bitte die Unterdruck Prüfdauer eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PPVT").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PPVZ").Enabled = True And ActiveDocument.FormFields("PPVZ").Result = "" Then
- MsgBox "Bitte die Unterdruck Prüfzyklen eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PPVZ").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("PPN").Enabled = True And ActiveDocument.FormFields("PPN").Result = "" Then
- MsgBox "Bitte Name des Prüfers eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("PPN").Select
- Exit Function
- End If
- If ComboBox1.Text = " " Then
- MsgBox "Bitte Gerätestatus auswählen!"
- Checkfields = False
- ComboBox1.Select
- Exit Function
- End If
- If ComboBox2.Text = " " Then
- MsgBox "Bitte Wartungszyklus auswählen!"
- Checkfields = False
- ComboBox2.Select
- Exit Function
- End If
- If ActiveDocument.FormFields("Ort").Result = "" Then
- MsgBox "Bitte Ort eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("Ort").Select
- Exit Function
- End If
- If ActiveDocument.FormFields("Aussteller").Result = "" Then
- MsgBox "Bitte Aussteller eintragen!"
- Checkfields = False
- ActiveDocument.FormFields("Aussteller").Select
- Exit Function
- End If
- Checkfields = True
- End Function
- Private Sub A1_Click()
- If A1.Value = True Then
- A2.Value = False
- End If
- End Sub
- Private Sub A2_Click()
- If A2.Value = True Then
- A1.Value = False
- End If
- End Sub
- Private Sub ColorBarAX11_GotFocus()
- End Sub
- Private Sub armaturBild_Click()
- If ActiveDocument.ProtectionType <> wdNoProtection Then
- ActiveDocument.Unprotect Password:=""
- ActiveDocument.ToggleFormsDesign
- End If
- End Sub
- Private Sub ComboBox2_DropButtonClick()
- ComboBox2.List = Array(" ", "1 Monat", "2 Monate", "3 Monate", "6 Monate", "12 Monate")
- End Sub
- Private Sub Image1_Click()
- End Sub
- Private Sub O1A_Click()
- If O1A.Value = True Then
- O1B.Value = False
- End If
- End Sub
- Private Sub O1B_Click()
- If O1B.Value = True Then
- O1A.Value = False
- End If
- End Sub
- Private Sub O2A_Click()
- If O2A.Value = True Then
- O2B.Value = False
- O2C.Value = False
- ActiveDocument.FormFields("PEPP").Enabled = True
- ActiveDocument.FormFields("PEPT").Enabled = True
- ActiveDocument.FormFields("PEPZ").Enabled = True
- ActiveDocument.FormFields("PEVP").Enabled = True
- ActiveDocument.FormFields("PEVT").Enabled = True
- ActiveDocument.FormFields("PEVZ").Enabled = True
- ActiveDocument.FormFields("PEN").Enabled = True
- ActiveDocument.FormFields("PPPP").Enabled = False
- ActiveDocument.FormFields("PPPT").Enabled = False
- ActiveDocument.FormFields("PPPZ").Enabled = False
- ActiveDocument.FormFields("PPVP").Enabled = False
- ActiveDocument.FormFields("PPVT").Enabled = False
- ActiveDocument.FormFields("PPVZ").Enabled = False
- ActiveDocument.FormFields("PPN").Enabled = False
- ActiveDocument.FormFields("PPPP").Result = ""
- ActiveDocument.FormFields("PPPT").Result = ""
- ActiveDocument.FormFields("PPPZ").Result = ""
- ActiveDocument.FormFields("PPVP").Result = ""
- ActiveDocument.FormFields("PPVT").Result = ""
- ActiveDocument.FormFields("PPVZ").Result = ""
- ActiveDocument.FormFields("PPN").Result = ""
- End If
- End Sub
- Private Sub O2B_Click()
- If O2B.Value = True Then
- O2A.Value = False
- O2C.Value = False
- ActiveDocument.FormFields("PEPP").Enabled = False
- ActiveDocument.FormFields("PEPT").Enabled = False
- ActiveDocument.FormFields("PEPZ").Enabled = False
- ActiveDocument.FormFields("PEVP").Enabled = False
- ActiveDocument.FormFields("PEVT").Enabled = False
- ActiveDocument.FormFields("PEVZ").Enabled = False
- ActiveDocument.FormFields("PEN").Enabled = False
- ActiveDocument.FormFields("PPPP").Enabled = True
- ActiveDocument.FormFields("PPPT").Enabled = True
- ActiveDocument.FormFields("PPPZ").Enabled = True
- ActiveDocument.FormFields("PPVP").Enabled = True
- ActiveDocument.FormFields("PPVT").Enabled = True
- ActiveDocument.FormFields("PPVZ").Enabled = True
- ActiveDocument.FormFields("PPN").Enabled = True
- ActiveDocument.FormFields("PEPP").Result = ""
- ActiveDocument.FormFields("PEPT").Result = ""
- ActiveDocument.FormFields("PEPZ").Result = ""
- ActiveDocument.FormFields("PEVP").Result = ""
- ActiveDocument.FormFields("PEVT").Result = ""
- ActiveDocument.FormFields("PEVZ").Result = ""
- ActiveDocument.FormFields("PEN").Result = ""
- End If
- End Sub
- Private Sub O2C_Click()
- If O2C.Value = True Then
- O2A.Value = False
- O2B.Value = False
- ActiveDocument.FormFields("PEPP").Enabled = False
- ActiveDocument.FormFields("PEPT").Enabled = False
- ActiveDocument.FormFields("PEPZ").Enabled = False
- ActiveDocument.FormFields("PEVP").Enabled = False
- ActiveDocument.FormFields("PEVT").Enabled = False
- ActiveDocument.FormFields("PEVZ").Enabled = False
- ActiveDocument.FormFields("PEN").Enabled = False
- ActiveDocument.FormFields("PPPP").Enabled = False
- ActiveDocument.FormFields("PPPT").Enabled = False
- ActiveDocument.FormFields("PPPZ").Enabled = False
- ActiveDocument.FormFields("PPVP").Enabled = False
- ActiveDocument.FormFields("PPVT").Enabled = False
- ActiveDocument.FormFields("PPVZ").Enabled = False
- ActiveDocument.FormFields("PPN").Enabled = False
- ActiveDocument.FormFields("PEPP").Result = ""
- ActiveDocument.FormFields("PEPT").Result = ""
- ActiveDocument.FormFields("PEPZ").Result = ""
- ActiveDocument.FormFields("PEVP").Result = ""
- ActiveDocument.FormFields("PEVT").Result = ""
- ActiveDocument.FormFields("PEVZ").Result = ""
- ActiveDocument.FormFields("PEN").Result = ""
- ActiveDocument.FormFields("PPPP").Result = ""
- ActiveDocument.FormFields("PPPT").Result = ""
- ActiveDocument.FormFields("PPPZ").Result = ""
- ActiveDocument.FormFields("PPVP").Result = ""
- ActiveDocument.FormFields("PPVT").Result = ""
- ActiveDocument.FormFields("PPVZ").Result = ""
- ActiveDocument.FormFields("PPN").Result = ""
- End If
- End Sub
- Private Sub FFJA_Click()
- If FFJA.Value = True Then
- FFNEIN.Value = False
- ActiveDocument.FormFields("FFA").Enabled = True
- ActiveDocument.FormFields("SW").Enabled = True
- ActiveDocument.FormFields("WR").Enabled = True
- ActiveDocument.FormFields("FFWRKST").Enabled = True
- ActiveDocument.FormFields("FKWRKST").Enabled = True
- ActiveDocument.FormFields("ZWL").Enabled = True
- End If
- End Sub
- Private Sub FFNEIN_Click()
- If FFNEIN.Value = True Then
- FFJA.Value = False
- ActiveDocument.FormFields("FFA").Enabled = False
- ActiveDocument.FormFields("SW").Enabled = False
- ActiveDocument.FormFields("WR").Enabled = False
- ActiveDocument.FormFields("FFWRKST").Enabled = False
- ActiveDocument.FormFields("FKWRKST").Enabled = False
- ActiveDocument.FormFields("ZWL").Enabled = False
- End If
- End Sub
- Private Sub O4A_Click()
- If O4A.Value = True Then
- O4B.Value = False
- End If
- End Sub
- Private Sub O4B_Click()
- If O4B.Value = True Then
- O4A.Value = False
- End If
- End Sub
- Private Sub PEPP_Change()
- End Sub
- Private Sub PPPP_Change()
- End Sub
Der Zweite Teil welcher die Daten an Excel übertragen soll befindet sich in einem extra Modul Namens Word2Excel.
Visual Basic-Quellcode
- Option Explicit
- Private Sub Transfer_Data()
- Dim xlApp As Object
- Dim xlWBook As Object
- Dim fld As FormField
- Dim nRow As Long
- Dim nCol As Integer
- Set xlApp = CreateObject("excel.Application")
- Set xlWBook = xlApp.Workbooks.Open(ThisDocument.Path & "\artexGeräteliste.xlsx")
- xlWBook.Application.Visible = True
- xlWBook.Application.Sheets("Geräteübersicht").Select
- nRow = xlWBook.Application.Range("A65536").End(xlUp).Row + 1
- 'ActiveDocument.Unprotect
- nCol = 4
- nInstall = ActiveDocument.FormFields("Gebäude").Result
- nEqui = ActiveDocument.FormFields("EquiNr").Result
- nTyp = ActiveDocument.FormFields("Typ").Result
- nPTB = ActiveDocument.FormFields("PTB").Result
- nSNR = ActiveDocument.FormFields("SNR").Result
- nFFA = ActiveDocument.FormFields("FFA").Result
- nPMBAR = ActiveDocument.FormFields("PMBAR").Result
- nVMBAR = ActiveDocument.FormFields("VMBAR").Result
- nPVDTNG = ActiveDocument.FormFields("PVDTNG").Result
- nVVDTNG = ActiveDocument.FormFields("VVDTNG").Result
- nMWRKST = ActiveDocument.FormFields("MWRKST").Result
- nProzMed = ActiveDocument.FormFields("ProzMed").Result
- xlWBook.Application.Cells(nRow, 2).Value = ActiveDocument.FormFields("Gebäude").Result
- xlWBook.Application.Cells(nRow, 3).Value = ActiveDocument.FormFields("EquiNr").Result
- xlWBook.Application.Cells(nRow, 4).Value = ActiveDocument.FormFields("Typ").Result
- xlWBook.Application.Cells(nRow, 5).Value = ActiveDocument.FormFields("PTB").Result
- xlWBook.Application.Cells(nRow, 6).Value = ActiveDocument.FormFields("SNR").Result
- xlWBook.Application.Cells(nRow, 7).Value = ActiveDocument.FormFields("FFA").Result
- xlWBook.Application.Cells(nRow, 8).Value = ActiveDocument.FormFields("PMBAR").Result
- xlWBook.Application.Cells(nRow, 9).Value = ActiveDocument.FormFields("VMBAR").Result
- xlWBook.Application.Cells(nRow, 10).Value = ActiveDocument.FormFields("PVDTNG").Result
- xlWBook.Application.Cells(nRow, 11).Value = ActiveDocument.FormFields("VVDTNG").Result
- xlWBook.Application.Cells(nRow, 12).Value = ActiveDocument.FormFields("MWRKST").Result
- xlWBook.Application.Cells(nRow, 13).Value = ActiveDocument.FormFields("ProzMed").Result
- ActiveDocument.Fields(1).Select
- xlWBook.Close savechanges:=True
- ActiveDocument.FormFields("Gebäude").Result = nInstall
- ActiveDocument.FormFields("EquiNr").Result = nEqui
- ActiveDocument.FormFields("Typ").Result = nTyp
- ActiveDocument.FormFields("PTB").Result = nPTB
- ActiveDocument.FormFields("SNR").Result = nSNR
- ActiveDocument.FormFields("FFA").Result = nFFA
- ActiveDocument.FormFields("PMBAR").Result = nPMBAR
- ActiveDocument.FormFields("VMBAR").Result = nVMBAR
- ActiveDocument.FormFields("PVDTNG").Result = nPVDTNG
- ActiveDocument.FormFields("VVDTNG").Result = nVVDTNG
- ActiveDocument.FormFields("MWRKST").Result = nMWRKST
- ActiveDocument.FormFields("ProzMed").Result = nProzMed
- End Sub
Ich hoffe das mir hier jemand helfen kann.
Fürs anschauen vielen Dank im Voraus.