range cannot be deleted

T

Tom Thompson

I am learning VBA in word from a book so please be patient with me.

Anyone have an idea what causes this error...

60208 The range cannot be deleted.

I can go more into detail if needed. Thanks for any help!
 
D

Doug Robbins - Word MVP

Hi Tom,

What line of the code is highlighted when you get the error?

Assuming that the template Test_Fax.dot \contains that bookmark, any
document created from that template will also contain it and it is not
therefore necessary to test for its existence.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
T

Tom Thompson

Doug, Thanks for the input so far..

objNewDoc.Bookmarks("bkmTo").Range.Text = strTo

causes the error.


I am working my way through the book Word 2000 VBA programmers
reference by Duncan Mackenzie and am trying to follow his code, but am
running into this error.
 
D

Doug Robbins - Word MVP

Hi Tom,

Are you sure that the bookmark "bkmTo" exists in the document? Or more
correctly in the template Test_Fax.dot?

Also, are you sure you quoted the error message correctly? There is nothing
being deleted by the code that you have shown us.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
T

Tom Thompson

Doug,

Im sure that is the error. I have seen it about a hundred times over
the last few dayss trying to figure it out. And the bookmark does
exist in the template. I've deleted it and added it several times to
verify and used Goto under the edit toolbar.

In the templater the bkmto bookmark is assigned to a field that has
the field code { MACROBUTTON NoMacro (Click to enter To) }

Is it possible that assigned the value of the variable to the field is
trying to replace the field code and this is where the error is being
generated?

As you can tel, im shooting in the dark at this point.

Thanks!
 
D

Doug Robbins - Word MVP

Hi Tom,

Well, I have never used a macrobutton nomacro so I can't really advise on
that. I will say though that, few books as I have read, some of them start
off trying get you to do things that are not at all the best way of
achieving something. I assume from the name of your template that it is to
be used for creating a fax in which you probably want to be able to enter
items such as the Addressee, their fax number, persons to whom you may want
to send a copy, the subject and the name of the sender. For this sort of
thing, it would be far better to start out in the first place with a
userform and forget about macrobuttons.

See the article "How to create a Userform" at:

http://www.mvps.org/word/FAQs/Userforms/CreateAUserForm.htm

and for some more detailed information on the subject of forms, see

http://www.mousetrax.com/techpage.html#autoforms

Please Fill Out This Form
Part 1: Create professional looking forms in Word
http://www.computorcompanion.com/LPMArticle.asp?ID=22

Part 2: Adding Automation to your Word forms.
http://www.computorcompanion.com/LPMArticle.asp?ID=46

Part 3: Learn more VBA (macros) to automate your forms.
http://www.computorcompanion.com/LPMArticle.asp?ID=119

Part 4: Use custom dialog boxes in your Word forms
http://www.computorcompanion.com/LPMArticle.asp?ID=127

Part 5: Connect your AutoForm to a database to save input time and keep
better records!
http://www.computorcompanion.com/LPMArticle.asp?ID=136

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
J

Jay Freedman

Hi, Tom,

The only other time I've seen this error was when a macro was trying to
replace the contents of the ActiveDocument.Range -- see this thread:

http://groups.google.com/[email protected]

FWIW, the code you posted worked perfectly for me (Word 2003 Beta on
WinXPpro)... Your code isn't doing the kind of assignment that caused the
problem in the other thread. Still, you may get better results if you
declare a Range object and use that as an intermediate. Try this:

Dim strWkgpTemplates As String, objNewDoc As Object
Dim strTo As String
Dim oRange As Range

strTo = "Name"

strWkgpTemplates = Options.DefaultFilePath(wdWorkgroupTemplatesPath)

Set objNewDoc = Documents.Add(strWkgpTemplates & "\FAX\Test_Fax.dot")

If objNewDoc.Bookmarks.Exists("bkmTo") Then
Set oRange = objNewDoc.Bookmarks("bkmTo").Range
oRange.Text = strTo
End If
 
T

Tom Thompson

Doug,

I guess I could of saved us alot of time if I mentioned what it was I
am trying to do at the get go. Your links tell me exactly what I need
to know and I am well on my way.

I have quite a few more questions, but I will try to answer them on my
own first before coming to the group for help.

Thanks for all your help and the below resources!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top