View Single Post
 
Old 06-05-2015, 12:28 PM
frustrated teacher frustrated teacher is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: May 2014
Posts: 12
frustrated teacher is on a distinguished road
Default Run-time error '5904' Cannot edit range.

Hello, I am running the following macro:

Sub ScratchMacroI()
Dim oRng As Word.Range
Dim oRngDelete As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "word"
While .Execute
oRng.Select
Set oRngDelete = ActiveDocument.Bookmarks("\Line").Range
oRngDelete.Delete
Wend
End With
End Sub
Sub ScratchMacroII()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "word"
While .Execute
oRng.Paragraphs(1).Range.Delete
Wend
End With
End Sub

It runs fine for awhile and then gets hung up on the run time error. I should mention the document I have is 200+ pages and is filled with tables. I have attached a sample of what these tables look like.
Attached Files
File Type: docx sample file.docx (11.9 KB, 13 views)
Reply With Quote