Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2021, 04:49 AM
stky stky is offline Convert all Frames to Text Windows 10 Convert all Frames to Text Office 2013
Advanced Beginner
Convert all Frames to Text
 
Join Date: Apr 2021
Posts: 30
stky is on a distinguished road
Default Convert all Frames to Text

If the document contain 0 frames to skip otherwise need to convert frames. Is the code is correct.




Sub RemoveAllFramesInDoc()
Dim objFrame As Frame
Dim nFrame As Long

Application.ScreenUpdating = False

nFrame = ActiveDocument.Frames.Count


For Each objFrame In ActiveDocument.Frames
If nFrame = 0 Then
End If
objFrame.Delete
Next objFrame
Application.ScreenUpdating = True
End Sub
Reply With Quote
  #2  
Old 12-05-2021, 06:41 AM
gmayor's Avatar
gmayor gmayor is offline Convert all Frames to Text Windows 10 Convert all Frames to Text Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You don't need to count the frames. If there are no frames there is nothing to loop thus either of the following will work.
Code:
Sub RemoveAllFramesInDoc1()
Dim objFrame As Frame
    Application.ScreenUpdating = False
    If ActiveDocument.Frames.Count = 0 Then Exit Sub 'optional
    For Each objFrame In ActiveDocument.Frames
        objFrame.Delete
    Next objFrame
    Application.ScreenUpdating = True
    Set objFrame = Nothing
End Sub


Sub RemoveAllFramesInDoc2()
Dim objFrame As Frame
Dim nFrame As Long, i As Long
    Application.ScreenUpdating = False
    nFrame = ActiveDocument.Frames.Count
    'If nFrame = 0 Then Exit Sub 'optional
    For i = nFrame To 1 Step -1
        Set objFrame = ActiveDocument.Frames(i)
        objFrame.Delete
    Next i
    Application.ScreenUpdating = True
    Set objFrame = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keyline Frames LesleyFromRicky Publisher 0 09-29-2019 01:39 AM
Convert all Frames to Text I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? AustinBrister Word VBA 8 05-28-2015 02:42 PM
Frames, Frames, Frames: How to eliminate them but keep the text? Dakota Word 10 02-09-2014 02:40 AM
My plain text post got converted to rich text in a reply, how to convert it back? david.karr Outlook 0 01-05-2012 09:46 AM
asp and frames HELP fatooma Misc 0 04-04-2006 01:04 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft