Se connecter avec Microsoft
S'identifier ou créer un compte.
Bonjour,
Sélectionnez un autre compte.
Vous avez plusieurs comptes
Choisissez le compte avec lequel vous voulez vous connecter.
Anglais
Désolé... Cet article n’est pas disponible dans votre langue.

Symptoms

When you try to run a Microsoft Visual Basic for Applications macro that creates or opens a Microsoft PowerPoint presentation, you may receive an error message that resembles the following error message:

Run-time error '-2147188160 (80048240)':

Application (unknown member): Invalid request. There is no currently active document window.

The same macro runs without error in Microsoft Office 97.

Cause

This behavior is caused by using any PowerPoint ActiveWindow or ActivePresentation property, method, or event when the PowerPoint program is not visible. The following sample code will cause this error.

Sub A()
Dim oPpt As PowerPoint.Application
Set oPpt = New PowerPoint.Application
oPpt.Presentations.Add
oPpt.Presentations(1).Slides.Add 1, ppLayoutBlank

'The following line causes the run-time error
msgbox oPpt.ActiveWindow.Caption

End Sub

Note This error message does not occur in Microsoft PowerPoint 97.

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. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

To work around this behavior, add the following lines of code once in any sub procedure before any ActiveWindow or ActivePresentation calls.

    If PowerPoint.Application.Version >= 9 Then
'window must be visible
PowerPoint.Application.Visible = msoTrue
End If

This code makes PowerPoint visible for Microsoft PowerPoint 2000 and for later versions of PowerPoint. PowerPoint 97 does not need to be made visible.

The sample code that is mentioned in the "Cause" section would change to the following code.

Sub A()
Dim oPpt As PowerPoint.Application
Set oPpt = New PowerPoint.Application
oPpt.Presentations.Add
oPpt.Presentations(1).Slides.Add 1, ppLayoutBlank
If oPpt.Version >= 9 Then
'window must be visible
oPpt.Visible = msoTrue
End If
oPpt.ActiveWindow.View.GotoSlide 1
End Sub

Note This workaround may not work for Microsoft Office PowerPoint 2007.

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Besoin d’aide ?

Vous voulez plus d’options ?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Ces informations vous ont-elles été utiles ?

Qu’est-ce qui a affecté votre expérience ?
En cliquant sur Envoyer, vos commentaires seront utilisés pour améliorer les produits et services de Microsoft. Votre administrateur informatique sera en mesure de collecter ces données. Déclaration de confidentialité.

Nous vous remercions de vos commentaires.

×