Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Jan 2003
    Location
    Brisbane, Queensland, Australia
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why Range.Delete failed? (Word 2003)

    Sometimes when I use Range.Delete to delete the whole range in a document, it fails (the return value is false). When I use Range.FormattedText to set the content of this Range, the new content does not replace the old content as it is supposed to do. It is inserted before the old content instead. Any one has a clue what makes the Range write-only?

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: Why Range.Delete failed? (Word 2003)

    Does it work better if you use ActiveDocument.Content instead of ActiveDocument.Range?

    If not, we'd need to have more information about the situation(s) and/or document(s) in which Delete fails.

  3. #3
    Lounger
    Join Date
    Jan 2003
    Location
    Brisbane, Queensland, Australia
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why Range.Delete failed? (Word 2003)

    I did more tests and got some detailed information.

    When the spelling and grammar check dialog is active, I can only perform Range.Delete in the active document. While I tried to do so in an inactive document, it failed. I tried it in a VBA macro, it pops out a message: " This method or property is not available because the proofing dialog is active."

    I cannot see any logic behind this rediculous limitation. I cannot activate a document just because I want to access it. Is there any way to avoid this problem?

    Thanks

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: Why Range.Delete failed? (Word 2003)

    The built-in dialogs and Word VBA use the same underlying engine; a lot of VBA code is unavailable when a built-in dialog is open. I don't know a workaround (except, of course, closing the dialog before running the code).

  5. #5
    Lounger
    Join Date
    Jan 2003
    Location
    Brisbane, Queensland, Australia
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why Range.Delete failed? (Word 2003)

    Thanks Hans. That solves my puzzle.

    Are there any information that clears lists which VBA methods are not available when which dialogs are active?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Re: Why Range.Delete failed? (Word 2003)

    I've never seen such a list. All modal dialogs (dialogs that won't allow you to click in the document while they're open) disable code execution if you haven't opened them in your code. With the modeless dialogs such as Insert | Reference | Cross Reference the situation is not quite clear, and behavior appears to change between versions. I think it's best to err on the safe side: assume that code won't run correctly if the user has opened a dialog.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •