Private Function Dokumentwerte_Uebertragen() As Boolean
Dim i As Long
Dim pos As Long
Dim pos2 As Long
Dim Fieldlen As Long
Dim temp1 As String
Dim temp2 As String
If Param.DebugMode Then
DivFnkt.InsertJournale("EDKB12: Start Dokumentwerte_Uebertragen", clsDivFnkt.Enum_InfoTyp.Information)
End If
For i = 0 To Dokumentdaten.Rows.Count - 1
If Param.DebugMode Then
Try
temp1 = Dokumentdaten.Rows(i).Item("beginntextmarke")
Catch ex As Exception
temp1 = ""
End Try
Try
temp2 = Dokumentdaten.Rows(i).Item("feldname")
Catch ex As Exception
temp2 = ""
End Try
DivFnkt.InsertJournale("EDKB12: Dokumentwerte_Uebertragen:" & temp1 & ":" & temp2, clsDivFnkt.Enum_InfoTyp.Information)
End If
'Beginn-Textmarke
If Dokumentdaten.Rows(i).Item("aktiv") = True Then
If Dokumentdaten.Rows(i).Item("beginntextmarke") Is System.DBNull.Value Then
Dokumentdaten.Rows(i).Item("beginntextmarke") = ""
End If
If Dokumentdaten.Rows(i).Item("endetextmarke") Is System.DBNull.Value Then
Dokumentdaten.Rows(i).Item("endetextmarke") = ""
End If
If Dokumentdaten.Rows(i).Item("feldname") Is System.DBNull.Value Then
Dokumentdaten.Rows(i).Item("feldname") = ""
End If
If Dokumentdaten.Rows(i).Item("beginntextmarke") = "TGEDKCursor" Or _
Dokumentdaten.Rows(i).Item("beginntextmarke") = "TGEDKCursorB" Or _
Dokumentdaten.Rows(i).Item("feldname") = "TGEDKCursorB" Or _
Dokumentdaten.Rows(i).Item("feldname") = "TGEDKCursor" Then
Else
If Dokumentdaten.Rows(i).Item("beginntextmarke") <> "" And _
Dokumentdaten.Rows(i).Item("endetextmarke") = "" Then
Try
docword.Bookmarks.Item(Dokumentdaten.Rows(i).Item("beginntextmarke")).Select()
pos = docword.Bookmarks.Item(Dokumentdaten.Rows(i).Item("beginntextmarke")).Start
If Dokumentdaten.Rows(i).Item("used") = 1 Then
objword.Selection.Text = Dokumentdaten.Rows(i).Item("xvalue")
End If
pos2 = objword.Selection.End
If Microsoft.VisualBasic.Left(Dokumentdaten.Rows(i).Item("beginntextmarke"), 19) = "XTGEDKDirektTelefonB" Or _
Microsoft.VisualBasic.Left(Dokumentdaten.Rows(i).Item("beginntextmarke"), 23) = "XTGEDKVornameNameBetreue" Or _
Microsoft.VisualBasic.Left(Dokumentdaten.Rows(i).Item("beginntextmarke"), 19) = "XTGEDKDirektTelefonZ" Then
objword.Selection.MoveLeft(Unit:=WdUnits.wdCharacter, Count:=1)
'hutter
objword.Selection.TypeText(Text:=" ")
objword.Selection.SetRange(Start:=pos + 1, End:=pos2 + 1)
With docword.Bookmarks
.Add(Range:=objword.Selection.Range, Name:=Dokumentdaten.Rows(i).Item("beginntextmarke"))
.DefaultSorting = WdBookmarkSortBy.wdSortByName
.ShowHidden = False
End With
Else
If Microsoft.VisualBasic.Left(Dokumentdaten.Rows(i).Item("beginntextmarke"), 22) = "XTGEDKDirektTelefonDokZ" Or _
Microsoft.VisualBasic.Left(Dokumentdaten.Rows(i).Item("beginntextmarke"), 20) = "XTGEDKVornameNameDokZ" Then
objword.Selection.Text = Dokumentdaten.Rows(i).Item("xvalue")
objword.Selection.MoveLeft(Unit:=WdUnits.wdCharacter, Count:=1)
objword.Selection.TypeText(Text:=" ")
objword.Selection.SetRange(Start:=pos + 1, End:=pos2 + 1)
With docword.Bookmarks
.Add(Range:=objword.Selection.Range, Name:=Dokumentdaten.Rows(i).Item("beginntextmarke"))
.DefaultSorting = WdBookmarkSortBy.wdSortByName
.ShowHidden = False
End With
Else
objword.Visible = True
objword.Selection.SetRange(Start:=pos, End:=pos2)
With docword.Bookmarks
.Add(Range:=objword.Selection.Range, Name:=Dokumentdaten.Rows(i).Item("beginntextmarke"))
.DefaultSorting = WdBookmarkSortBy.wdSortByName
.ShowHidden = False
End With
End If
End If
objword.Selection.MoveLeft(Unit:=WdUnits.wdCharacter, Count:=1)
objword.Selection.MoveLeft(Unit:=WdUnits.wdCharacter, Count:=2, Extend:=WdMovementType.wdExtend)
If objword.Selection.Text = " " Then
objword.Selection.MoveRight(Unit:=WdUnits.wdCharacter, Count:=1)
objword.Selection.MoveLeft(Unit:=WdUnits.wdCharacter, Count:=1, Extend:=WdMovementType.wdExtend)
objword.Selection.Delete(Unit:=WdUnits.wdCharacter, Count:=1)
End If
Catch
End Try
End If
'Beginn- und Ende-Textmarke
If Dokumentdaten.Rows(i).Item("beginntextmarke") <> "" And _
Dokumentdaten.Rows(i).Item("endetextmarke") <> "" Then
Try
docword.Bookmarks.Item(Dokumentdaten.Rows(i).Item("beginntextmarke")).Select()
pos = docword.Bookmarks.Item(Dokumentdaten.Rows(i).Item("beginntextmarke")).Start
docword.Bookmarks.Item(Dokumentdaten.Rows(i).Item("endetextmarke")).Select()
pos2 = docword.Bookmarks.Item(Dokumentdaten.Rows(i).Item("endetextmarke")).Start
objword.Selection.SetRange(Start:=pos, End:=pos2)
If Dokumentdaten.Rows(i).Item("used") = 1 Then
objword.Selection.TypeText(Text:=Dokumentdaten.Rows(i).Item("xvalue"))
End If
With docword.Bookmarks
.Add(Range:=objword.Selection.Range, Name:=Dokumentdaten.Rows(i).Item("beginntextmarke"))
.DefaultSorting = WdBookmarkSortBy.wdSortByName
.ShowHidden = False
End With
Catch
End Try
End If
'Felder
If Dokumentdaten.Rows(i).Item("feldname") <> "" Then
Try
If docword.FormFields.Item(Dokumentdaten.Rows(i).Item("feldname")).TextInput.Width <> 0 Then
Fieldlen = docword.FormFields.Item(Dokumentdaten.Rows(i).Item("feldname")).TextInput.Width
docword.FormFields.Item(Dokumentdaten.Rows(i).Item("feldname")).TextInput.Width = Fieldlen + 5
End If
If Dokumentdaten.Rows(i).Item("used") = 1 Then
docword.FormFields.Item(Dokumentdaten.Rows(i).Item("feldname")).Result = convert_wordfelder(Dokumentdaten.Rows(i).Item("xvalue"))
End If
Catch
End Try
End If
End If
End If
Next
If Param.DebugMode Then
DivFnkt.InsertJournale("EDKB12: Start Ende Dokumentwerte_Uebertragen", clsDivFnkt.Enum_InfoTyp.Information)
End If
Return True
End Function
|