Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2007

Tip: Looking for answers? Try searching our database.

Can't edit range

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alexander Mueller - 19 Jul 2007 15:21 GMT
Hi @ all

i want to copy a document and then remove some parts of it.

I do the copy with WordBasic.CopyFileA, since VBA.FileCopy
fails on opened docs.
After having copied the file, I open it using
Documents.Open in invisible manner.

Then I want to remove the first part of the document , from the
very beginning to one char before a certain bookmark

I use the following code

 Set oRng = oNewDoc.Range(0, oNewDoc.Bookmark("bmname").Start - 1)
 oRng.Delete

However i get error 5904, "Cannot edit range" on the delete statement

What may be the reason for this?

Strangely it worked until I changed the bookmark "bmname" from being
a 1 char-bookmark to one that extends over a table and a pagebreak.
But the range to delete doesn't overlap with this bookmark's range,
so i wonder why there seems to be an interference.

Any hints much appreciated!

TIA & bye,
Alex
David Sisson - 19 Jul 2007 19:48 GMT
Change Bookmark to Bookmarks
Alexander Mueller - 19 Jul 2007 19:56 GMT
David Sisson schrieb:
> Change Bookmark to Bookmarks

sorry
that was an error only in the posted code
didn't c&p it. It's bookmarks in the project.

MfG,
Alex
David Sisson - 19 Jul 2007 20:08 GMT
I made a sample doc just as you described and it work perfectly.

Post the original code.
Klaus Linke - 20 Jul 2007 00:13 GMT
Hi Alexander,

Have you checked whether the range you're trying to delete contains a
paragraph mark right in front of a table?

Klaus

> David Sisson schrieb:
>> Change Bookmark to Bookmarks
[quoted text clipped - 5 lines]
> MfG,
> Alex
Alexander Mueller - 23 Jul 2007 09:18 GMT
Klaus Linke schrieb:
> Hi Alexander,
>
> Have you checked whether the range you're trying to delete contains a
> paragraph mark right in front of a table?
>
> Klaus

Hi Klaus and David

Thanks for your hints and support.
The reason was, that the last chaarcter of the range to delete was
a paragraph-mark directly following a table. So Klaus was right with
his assumption! After adding an additional dummy-paragraph it works
as desired.

MfG,
Alex
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.