Partager via

Excel.Application

Anonyme
2018-11-26T21:22:52+00:00

Bonjour,

J'essaye de créer un fichier excel de word (VBA).

Par contre, dès le début de mon code, j'ai une erreur avec la première ligne.

Que ce passe-t'il?

   Dim xlpp As Excel.Application

Erreur de compilation

Merci,

Microsoft 365 et Office | Word | Pour la maison | Windows

Question verrouillée. Cette question a été migrée à partir de la Communauté Support Microsoft. Vous pouvez voter pour indiquer si elle est utile, mais vous ne pouvez pas ajouter de commentaires ou de réponses ni suivre la question.

0 commentaires Aucun commentaire

Réponse acceptée par l’auteur de la question

Doug Robbins - MVP - Office Apps and Services 323.1K Points de réputation MVP Modérateur bénévole
2018-11-26T21:39:10+00:00

If you are going to use Early Binding based on your declaration of  xlpp in that way, you will need to set a reference under Tools>References in the Visual Basic Editor to the Microsoft Excel 16.0 Object Library.

If your application is likely to be used by people with earlier versions of Office, you should use Late Binding as follows:

Dim xlapp As Object

Dim xlbook As Object

Dim xlsheet As Object

On Error Resume Next

Set xlapp = GetObject(, "Excel.Application")

If Err Then

    bstartApp = True

    Set xlapp = CreateObject("Excel.Application")

End If

On Error GoTo 0

When you use Late Binding, you do not need a reference to the Excel Object Model and your code will run on any version of Office.

See the article "Early vs. Late Binding” at:

http://wordmvp.com/FAQs/InterDev/EarlyvsLateBinding.htm

Cette réponse a-t-elle été utile ?

3 personnes ont trouvé cette réponse utile.
0 commentaires Aucun commentaire

0 réponses supplémentaires