WD2000: Range.Delete Causes Invalid Page Fault with GetObject (220211)



The information in this article applies to:

  • Microsoft Word 2000

This article was previously published under Q220211

SYMPTOMS

When you use the Visual Basics for Applications Range.Delete command with a document object that you set using the Visual Basics for Applications GetObject function, the following error message may appear when there are no documents open in Word:
This program has performed an illegal operation and will be shut down.

If the problem persists, contact the program vendor.
When you click Details, the following message is displayed:
WINWORD caused an invalid page fault in WINWORD.EXE at 015f:30139205.
NOTE: The actual memory address may vary.

WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To work around this problem, you can make sure that at least one document is open in Word. The following sample Visual Basic for Applications procedure demonstrates this workaround:
Sub RangeDelete()
   Dim getDoc As Document
   Dim emptyDoc As Document
   If Douments.Count = 0 Then              ' If no documents are open,
      Set EmptyDoc = Documents.Add         ' Create a blank document.
   End If
   Set getDoc = GetObject("C:\MyDoc.doc")
   With getDoc
      .Range.Delete
      .Save
      .Close
   End With
   emptyDoc.Close
   Set getDoc = Nothing
   Set emptyDoc = Nothing
End Sub
				

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

Modification Type:MajorLast Reviewed:6/17/2005
Keywords:kbbug kbpending KB220211