Hi Guys,
I have wrote the macro where I am looping throw word document and delete contentcontrols where there is no checkbox = true:
This is working very well.
My document BEFORE macro looks like:
And after macro looks like:
The problem is that when I am using Delete property - this working fine but it left empty lines between point 1 and 4.
So insted of delete property there should be Backspace there.
Something like this:
contentcontrol.delete backspace or contentcontrol.paragraph delete.
Is there any solution for this?
I will appreciate any kind of your support and help,
Thank You
Jacek Antek
I have wrote the macro where I am looping throw word document and delete contentcontrols where there is no checkbox = true:
Code:
Dim applWord As Object
Dim docWord As Object
Dim DocActive As Object
Dim Path_Folder As String
Dim Path_Plik As String
Dim Nazwa_Dokumentu As String
Dim Nazwa_Dokumentu_temp As String
Dim str_tmppath As String
Dim Wiersz_wpisy As Long
Dim ContentItems As Object
Dim i As Integer
Dim Dictionary_Word As Object
Set Dictionary_Word = CreateObject("Scripting.Dictionary")
Dim counter As Integer
Dim ExcVariable As String
Dim Wbworkbook As Workbook
Dim Wysokosc As Integer
Dim Szerokosc As Integer
Dim SmallVariable As Integer
Dim Licznikus As Integer
Set applWord = CreateObject("Word.Application")
applWord.Visible = True
Set docWord = applWord.Documents.Open(Path_Plik)
For Each ContentItems In docWord.contentcontrols
Licznikus = Licznikus + 1
If Licznikus > 4 Then
ContentItems.Paragraphs.Delete
Debug.Print ContentItems.Tag
Debug.Print ContentItems.Type
If ContentItems.Type = "1" Then
GoTo Nastepca
ElseIf ContentItems.Type = "8" And ContentItems.Checked = True Then
If Err.Number <> 0 Then
GoTo Nastepca
End If
counter = counter + 1
Dictionary_Word.Add ContentItems.Tag, 1
Dim vkeys, vitems
vkeys = Dictionary_Word.keys
vitems = Dictionary_Word.items
Else
Nastepca:
If Not Dictionary_Word.exists(ContentItems.Tag) Then
ContentItems.Delete True
End If
End If
End If
Next ContentItems
This is working very well.
My document BEFORE macro looks like:
And after macro looks like:
The problem is that when I am using Delete property - this working fine but it left empty lines between point 1 and 4.
So insted of delete property there should be Backspace there.
Something like this:
contentcontrol.delete backspace or contentcontrol.paragraph delete.
Is there any solution for this?
I will appreciate any kind of your support and help,
Thank You
Jacek Antek
Last edited: