Hi, I'm trying to use VBA to see if a section exists in my Word document, and if it does, delete it... I will then add a section again and insert some auto text (This part is working fine).
The trouble I'm having, is with the "If a section exists" part.
I have used the following code which works, but ONLY if the section exists (it errors if the sections don't exist):
Dim SECS As Word.Section
Set SECS = ActiveDocument.Sections(7)
SECS.Range.Select
SECS.Range.Delete
Dim SECS1 As Word.Section
Set SECS1 = ActiveDocument.Sections(6)
SECS1.Range.Select
SECS1.Range.Delete
Any help would be much appreciated
The trouble I'm having, is with the "If a section exists" part.
I have used the following code which works, but ONLY if the section exists (it errors if the sections don't exist):
Dim SECS As Word.Section
Set SECS = ActiveDocument.Sections(7)
SECS.Range.Select
SECS.Range.Delete
Dim SECS1 As Word.Section
Set SECS1 = ActiveDocument.Sections(6)
SECS1.Range.Select
SECS1.Range.Delete
Any help would be much appreciated