PPT2002: Run-time Error -2147024809 When You Attempt to Change Views with Visual Basic for Applications (285305)
The information in this article applies to:
- Microsoft PowerPoint 2002
This article was previously published under Q285305 SYMPTOMS
When you run a Microsoft Visual Basic for Applications macro with Microsoft PowerPoint, you may receive an error message similar to the following:
Run-time error: '-2147024809 (80070057)'
DocumentWindow (unknown member): Invalid enumeration value.
CAUSE
This behavior is caused by PowerPoint's inability to change to certain views when running Visual Basic for Application macros. When you change the ViewType property to ppViewThumbnails or ppViewMasterThumbnails, the view does not change, and this run-time error message is displayed.
WORKAROUND
To work around this issue, you can add code to your macro to trap this function and change the view back to the previous view. To create a sample macro of this sort, follow these steps:
- Start PowerPoint and then create a new presentation.
- Click Tools, point to Macro, and then click Visual Basic Editor (or press ALT+F11).
- Type or paste the following code in the module:
Sub A()
NewViewType = 11
' 11 = Thumbnails, change this to change view
On Error Resume Next
Err.Clear
OldViewType = ActiveWindow.ViewType
' Save the current view type to revert to if there is an error.
ActiveWindow.ViewType = NewViewType
If Err.Number = -2147024809 Then
'Thumb-type view
ActiveWindow.ViewType = OldViewType
ElseIf Err.Number = -2147188160 Then
'Title master view without a title master
ActiveWindow.ViewType = OldViewType
End If
End Sub
- Click anywhere in the code of subprocedure A, and then on the Run menu, click Run Sub/UserForm.
You can change the NewViewType variable to different valid view types ranging from 1 to 12. Microsoft provides programming examples for illustration only, without warranty either
expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes
that you are familiar with the programming language being demonstrated and the
tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may
want to contact a Microsoft Certified Partner or the Microsoft fee-based
consulting line at (800) 936-5200. For more information about Microsoft Certified
Partners, please visit the following Microsoft Web site:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 5/13/2002 |
---|
Keywords: | kbbug kberrmsg KB285305 |
---|
|