Thread: [Solved] Macro not running
View Single Post
 
Old 08-12-2019, 06:08 AM
Ulodesk Ulodesk is offline Windows 7 64bit Office 2013
Word 2013 Expert Cert
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default Macro not running

At work last week, a proposal document of 120-plus pages developed a problem during a computer freeze. When the computer was rebooted and the document reopened, all of the text bullets had been changed to the table bullet style, and each group of bulleted items had been placed in a frame.

I found the macro below, posted in 2017 on the web, and tried to use it, selecting from just above the first set of bullets to the end of the document and running the macro. It only removed the first frame. Today, trying again, I find that the document gets busy for perhaps five seconds and then abruptly closes with no change.

Since I’m not a coder, I don’t really read VBA, but this looks pretty straight-forward to me. Is there anything wrong with the macro (I’m running Office 365 on a corporate network), is the problem perhaps a network security issue preventing its execution, or might there be some other reason it would not work on this document? The only frames are those added around the bullets. There are tables and text boxes but no other frames.

Thanks.

Code:
Sub RemoveAllFramesInDoc()
  Dim objFrame As Frame
  Dim nFrame As Long
 
  Application.ScreenUpdating = False
 
  nFrame = ActiveDocument.Frames.Count
 
  For Each objFrame In ActiveDocument.Frames
    objFrame.Delete
  Next objFrame
  MsgBox ("All " & nFrame & " frames in this document have been removed!")
 
  Application.ScreenUpdating = True
End Sub
Reply With Quote