Sub
DataTransfer()
Dim
xlApp
As
Object
Dim
xlWBook
As
Object
Dim
fld
As
FormField
Dim
nRow
As
Long
Dim
nCol
As
Integer
Dim
ws
As
Object
Dim
ldfNr
As
Integer
Dim
rng
As
Range
Const
xlUp = -4162
Application.ScreenUpdating =
False
Set
xlApp = CreateObject(
"excel.Application"
)
Set
xlWBook = xlApp.Workbooks.Open(ThisDocument.Path &
"\artexGeräteliste.xlsm"
)
xlWBook.Application.Visible =
True
xlWBook.Application.Sheets(
"Geräteübersicht"
).
Select
Set
ws = xlWBook.Sheets(
"Geräteübersicht"
)
nRow = ws.Cells(ws.Rows.Count, 4).
End
(xlUp).Row + 1
ldfNr = ws.Cells(ws.Rows.Count, 1).
End
(xlUp).Row
If
ldfNr = 0
Then
ws.Cells(ldfNr + 1, 1) = 1
Else
ws.Cells(ldfNr + 1, 1) = ldfNr - 2
End
If
nInstall = ActiveDocument.FormFields(
"Gebäude"
).Result &
" - "
& ActiveDocument.FormFields(
"ObjNr"
).Result
nEqui = ActiveDocument.FormFields(
"EquiNr"
).Result
nTyp = ActiveDocument.FormFields(
"Typ"
).Result &
"-"
& ActiveDocument.FormFields(
"TypAdd1"
).Result &
"-"
& ActiveDocument.FormFields(
"TypAdd2"
).Result
nPTB = ActiveDocument.FormFields(
"PTB"
).Result
nSNR = ActiveDocument.FormFields(
"SNR"
).Result
nFFA = ActiveDocument.FormFields(
"FFA"
).Result &
" x "
& ActiveDocument.FormFields(
"SW"
).Result &
" / "
& ActiveDocument.FormFields(
"ZWL"
).Result &
" / "
& ActiveDocument.FormFields(
"WR"
).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
nMedium = ActiveDocument.FormFields(
"Medium"
).Result
xlWBook.Application.Cells(nRow, 2).Value = ActiveDocument.FormFields(
"Gebäude"
).Result &
" - "
& ActiveDocument.FormFields(
"ObjNr"
).Result
xlWBook.Application.Cells(nRow, 2).HorizontalAlignment = xlCenter
xlWBook.Application.Cells(nRow, 3).Value = ActiveDocument.FormFields(
"EquiNr"
).Result
xlWBook.Application.Cells(nRow, 3).HorizontalAlignment = xlCenter
If
ActiveDocument.FormFields(
"TypAdd1"
).Result =
""
Then
xlWBook.Application.Cells(nRow, 4).Value = ActiveDocument.FormFields(
"Typ"
).Result &
"-"
& ActiveDocument.FormFields(
"TypAdd2"
).Result
xlWBook.Application.Cells(nRow, 4).HorizontalAlignment = xlCenter
Else
xlWBook.Application.Cells(nRow, 4).Value = ActiveDocument.FormFields(
"Typ"
).Result &
"-"
& ActiveDocument.FormFields(
"TypAdd1"
).Result &
"-"
& ActiveDocument.FormFields(
"TypAdd2"
).Result
xlWBook.Application.Cells(nRow, 4).HorizontalAlignment = xlCenter
End
If
xlWBook.Application.Cells(nRow, 7).Value = ActiveDocument.FormFields(
"PTB"
).Result
xlWBook.Application.Cells(nRow, 7).HorizontalAlignment = xlCenter
xlWBook.Application.Cells(nRow, 9).Value = ActiveDocument.FormFields(
"SNR"
).Result
xlWBook.Application.Cells(nRow, 9).HorizontalAlignment = xlCenter
If
ActiveDocument.FFNEIN.Value =
True
Then
xlWBook.Application.Cells(nRow, 8).Value =
"-"
xlWBook.Application.Cells(nRow, 8).HorizontalAlignment = xlCenter
Else
xlWBook.Application.Cells(nRow, 8).Value = ActiveDocument.FormFields(
"FFA"
).Result &
" x "
& ActiveDocument.FormFields(
"SW"
).Result &
" / "
& ActiveDocument.FormFields(
"ZWL"
).Result &
" / "
& ActiveDocument.FormFields(
"WR"
).Result
xlWBook.Application.Cells(nRow, 8).HorizontalAlignment = xlCenter
End
If
xlWBook.Application.Cells(nRow, 13).Value = ActiveDocument.FormFields(
"PMBAR"
).Result
xlWBook.Application.Cells(nRow, 13).HorizontalAlignment = xlCenter
xlWBook.Application.Cells(nRow, 14).Value = ActiveDocument.FormFields(
"VMBAR"
).Result
xlWBook.Application.Cells(nRow, 14).HorizontalAlignment = xlCenter
xlWBook.Application.Cells(nRow, 15).Value = ActiveDocument.FormFields(
"PVDTNG"
).Result
xlWBook.Application.Cells(nRow, 15).HorizontalAlignment = xlCenter
xlWBook.Application.Cells(nRow, 16).Value = ActiveDocument.FormFields(
"VVDTNG"
).Result
xlWBook.Application.Cells(nRow, 16).HorizontalAlignment = xlCenter
xlWBook.Application.Cells(nRow, 17).Value = ActiveDocument.FormFields(
"MWRKST"
).Result
xlWBook.Application.Cells(nRow, 17).HorizontalAlignment = xlCenter
xlWBook.Application.Cells(nRow, 18).Value = ActiveDocument.FormFields(
"Medium"
).Result
xlWBook.Application.Cells(nRow, 18).HorizontalAlignment = xlCenter
If
ActiveDocument.ComboBox1.Text =
"Armatur funktionssicher instandgesetzt."
Then
xlWBook.Application.Cells(nRow, 11).Value =
"OK"
xlWBook.Application.Cells(nRow, 11).HorizontalAlignment = xlCenter
xlWBook.Application.Cells(nRow, 11).Font.Color = RGB(34, 139, 34)
End
If
If
ActiveDocument.ComboBox1.Text =
"Weitere Maßnahmen erforderlich. (siehe Text)"
Then
xlWBook.Application.Cells(nRow, 11).Value =
"Beanstandet"
xlWBook.Application.Cells(nRow, 11).HorizontalAlignment = xlCenter
xlWBook.Application.Cells(nRow, 11).Interior.Color = RGB(255, 255, 0)
xlWBook.Application.Cells(nRow, 11).Font.Color = RGB(0, 0, 0)
End
If
If
ActiveDocument.ComboBox1.Text =
"Wartung nicht möglich. (siehe Text)"
Then
xlWBook.Application.Cells(nRow, 11).Value =
"ohne Wartung"
xlWBook.Application.Cells(nRow, 11).HorizontalAlignment = xlCenter
xlWBook.Application.Cells(nRow, 11).Interior.Color = RGB(255, 0, 0)
xlWBook.Application.Cells(nRow, 11).Font.Color = RGB(0, 0, 0)
End
If
If
ActiveDocument.ComboBox1.Text =
"Altarmatur - Zulassung zurückgezogen! (siehe Text)"
Then
xlWBook.Application.Cells(nRow, 11).Value =
"Altarmatur"
xlWBook.Application.Cells(nRow, 11).HorizontalAlignment = xlCenter
xlWBook.Application.Cells(nRow, 11).Interior.Color = RGB(255, 0, 0)
xlWBook.Application.Cells(nRow, 11).Font.Color = RGB(0, 0, 0)
End
If
If
ActiveDocument.ComboBox1.Text =
"Altarmatur - Zulassung eingeschränkt! (siehe Text)"
Then
xlWBook.Application.Cells(nRow, 11).Value =
"Altarmatur"
xlWBook.Application.Cells(nRow, 11).HorizontalAlignment = xlCenter
xlWBook.Application.Cells(nRow, 11).Font.Color = RGB(34, 139, 34)
End
If
If
ActiveDocument.ComboBox1.Text =
"Altarmatur - Zulassung eingeschränkt ! (siehe Text)"
Then
xlWBook.Application.Cells(nRow, 11).Value =
"Altarmatur"
xlWBook.Application.Cells(nRow, 11).HorizontalAlignment = xlCenter
xlWBook.Application.Cells(nRow, 11).Interior.Color = RGB(255, 255, 0)
xlWBook.Application.Cells(nRow, 11).Font.Color = RGB(0, 0, 0)
End
If
For
Each
rng
In
ActiveSheet.UsedRange
If
IsEmpty(rng)
Then
rng.Delete xlShiftUp
Next
rng
Application.ScreenUpdating =
True
xlWBook.Close SaveChanges:=
True
End
Sub