Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-05-2015, 12:28 PM
frustrated teacher frustrated teacher is offline Run-time error '5904' Cannot edit range. Windows 7 64bit Run-time error '5904' Cannot edit range. Office 2010 64bit
Novice
Run-time error '5904' Cannot edit range.
 
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, 11 views)
Reply With Quote
  #2  
Old 06-05-2015, 06:09 PM
gmaxey gmaxey is offline Run-time error '5904' Cannot edit range. Windows 7 32bit Run-time error '5904' Cannot edit range. Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,437
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

You posted two macros. Which one is giving you trouble? You might try adding a DoEvents statement after the Delete statements.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-time error '5904' Cannot edit range. Most active time range 1N82I Excel 3 02-08-2015 12:39 PM
Display and Edit a Presentation at the same time. Techabca PowerPoint 3 05-02-2014 11:00 AM
Run-time error '5904' Cannot edit range. Word VBA: Cannot Edit Range (Delete characters except the first in a table cell) tinfanide Word VBA 3 04-27-2012 09:48 AM
Word Visual Basic error - run time error 504 crazymorton Word 11 01-13-2012 04:32 AM
Can't delete range - error 5904 expatriate Word VBA 1 06-03-2011 12:12 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:02 AM.


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