R
Rhino
I'm looking for the "best" way of deleting all of the current contents of a
document from within a macro.
Originally, I was doing this and it worked fine:
'Erase all other content
For Each Wd In ActiveDocument.Words
Wd.Delete
Next Wd
However, as soon as my document got some tables added to it, they weren't
being deleted so I had to add this:
'Erase the existing tables
Dim oTable As Table
For Each oTable In ActiveDocument.Tables
oTable.Delete
Next oTable
I can just imagine having to add different loops to delete graphics or
tables of contents or whatever else the first loop doesn't touch.
I've got to believe there is a simple, direct way to delete the entire
contents of the document but I wasn't able to find one. For example, I'd
hoped that something like "ActiveDocument.Delete" might exist and do the job
but that particular method does not exist and I haven't found anything
analogous.
Does a simple, direct method exist or will I keep having to refine my
"eraseContents" routine as my document changes?
document from within a macro.
Originally, I was doing this and it worked fine:
'Erase all other content
For Each Wd In ActiveDocument.Words
Wd.Delete
Next Wd
However, as soon as my document got some tables added to it, they weren't
being deleted so I had to add this:
'Erase the existing tables
Dim oTable As Table
For Each oTable In ActiveDocument.Tables
oTable.Delete
Next oTable
I can just imagine having to add different loops to delete graphics or
tables of contents or whatever else the first loop doesn't touch.
I've got to believe there is a simple, direct way to delete the entire
contents of the document but I wasn't able to find one. For example, I'd
hoped that something like "ActiveDocument.Delete" might exist and do the job
but that particular method does not exist and I haven't found anything
analogous.
Does a simple, direct method exist or will I keep having to refine my
"eraseContents" routine as my document changes?