Delete all frames in a document including the text located in these frames

A

andreas

Dear Experts:
I would like to be able to delete ALL FRAMES in a document using VBA.
Below macro regrettably only deletes the frames but not the text that
is located in the frames. How can I ask Word to delete the frames
including the contents of these frames. Help is appreciated. Thank
you very much in advance.

Regards, Andreas

Sub RemoveFrames()
'Deleting all frames in a document
Dim frm As Frame
For Each frm In ActiveDocument.Frames
frm.Delete
Next frm
End Sub
 
G

Graham Mayor

You can delete the text with a frame parameter using Replace

Sub ReplaceExample()
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
'**********************
.Text = ""
.Frame.TextWrap = True
.Replacement.Text = ""
'**********************
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
.Execute replace:=wdReplaceAll
End With
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

andreas

You can delete the text with a frame parameter using Replace

Sub ReplaceExample()
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
'**********************
.Text = ""
.Frame.TextWrap = True
.Replacement.Text = ""
'**********************
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
.Execute replace:=wdReplaceAll
End With
End With
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>






- Zitierten Text anzeigen -

Graham,

thank you very much. It is working fine. Regards, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top