You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
3.7 KiB
83 lines
3.7 KiB
Imports Microsoft.Office.Interop.Word
|
|
Public Class clsAllgFnkt
|
|
|
|
Dim p_WDapp As Microsoft.Office.Interop.Word.Application
|
|
Dim p_Passwort As String = "Australia"
|
|
|
|
Public Function FormularAktualisieren(app As Object)
|
|
p_WDapp = app
|
|
On Error GoTo ErrHandler
|
|
|
|
' Variablen deklarieren
|
|
' *********************
|
|
Dim m_book1 As Bookmark
|
|
Dim m_bookE As Bookmark
|
|
Dim m_bookP As Bookmark
|
|
Dim m_strName As String
|
|
Dim m_range As Range
|
|
Dim m_boolGeschuetzt As Boolean
|
|
Dim m_FormField As FormField
|
|
|
|
p_WDapp.Application.ScreenUpdating = False
|
|
|
|
' Dokumentschutz aufheben
|
|
' ***********************
|
|
If p_WDapp.ActiveDocument.ProtectionType <> WdProtectionType.wdNoProtection Then
|
|
p_WDapp.ActiveDocument.Unprotect(p_Passwort)
|
|
m_boolGeschuetzt = True
|
|
End If
|
|
|
|
' Textmarken suchen und Texte kopieren
|
|
' ************************************
|
|
For Each m_book1 In p_WDapp.ActiveDocument.Bookmarks
|
|
If Mid(m_book1, 1, 10) = "BkmFormPos" Then
|
|
p_WDapp.Selection.GoTo(Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark, , , m_book1)
|
|
p_WDapp.Selection.Copy()
|
|
For Each m_bookE In p_WDapp.ActiveDocument.Bookmarks
|
|
If m_bookE.ToString <> m_strName Then
|
|
If Mid(m_bookE, 1, 10) = "BkmFormEin" Then
|
|
If Mid(m_bookE, 11, 2) = Mid(m_book1, 11, 2) Then
|
|
m_strName = m_bookE.Name
|
|
p_WDapp.Selection.GoTo(Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark, , , m_bookE)
|
|
p_WDapp.Selection.MoveLeft(Microsoft.Office.Interop.Word.WdUnits.wdCharacter, 1, False)
|
|
p_WDapp.Selection.Bookmarks.Add("BkmBeginn")
|
|
p_WDapp.Selection.GoTo(Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark, , , m_bookE)
|
|
p_WDapp.Selection.Paste()
|
|
p_WDapp.Selection.Bookmarks.Add("BkmEnde")
|
|
m_range = p_WDapp.ActiveDocument.Range(p_WDapp.ActiveDocument.Bookmarks("BkmBeginn").Start, p_WDapp.ActiveDocument.Bookmarks("BkmEnde").End)
|
|
p_WDapp.Selection.GoTo(Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark, , , "BkmBeginn")
|
|
m_range.Bookmarks.Add(m_strName)
|
|
p_WDapp.Selection.GoTo(Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark, , , m_strName)
|
|
p_WDapp.Selection.Fields.Unlink()
|
|
For Each m_FormField In p_WDapp.Selection.FormFields
|
|
m_FormField.Enabled = False
|
|
Next
|
|
End If
|
|
End If
|
|
End If
|
|
Next m_bookE
|
|
End If
|
|
Next m_book1
|
|
|
|
' Textmarke setzen bereits erstellt
|
|
' *********************************
|
|
p_WDapp.Selection.HomeKey(Microsoft.Office.Interop.Word.WdUnits.wdStory)
|
|
p_WDapp.Selection.NextField()
|
|
|
|
' Dokumentschutz einschalten
|
|
' **************************
|
|
If m_boolGeschuetzt = True Then
|
|
p_WDapp.ActiveDocument.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyFormFields, True, p_Passwort)
|
|
End If
|
|
|
|
p_WDapp.ActiveDocument.Fields.Update()
|
|
|
|
p_WDapp.Application.ScreenUpdating = True
|
|
|
|
Exit Function
|
|
|
|
ErrHandler:
|
|
MsgBox(Err.Description, vbCritical + vbOKOnly, "IDV-Portefeuille Makros")
|
|
End Function
|
|
End Class
|