Excel ouvrire un fichier word

Résolu
tas6705 -  
 tas6705 -
Bonjour,

sous VBA : Je voudrai ouvrir un fichier Word "C:\Documents and Settings\cochoum\My Document\Rapport.doc" juste en appuyant sur un commandbox.

Ps: je suis sous XP et office 2003.

Merci d'avance.

2 réponses

  1. dominiquedfci
     
    Bonsoir,

    Après avoir référencé la bibliothèque :

    Microsoft Word 12 Object Library dans outils / références

    Saisie le code suivant :

    dans la partie Général / déclarations :

    Option Explicit
    'Déclaration des variables
    Dim wApp As Word.Application
    Dim wDoc As Word.Document


    créer une nouvelle procédure de type SUB :

    Public Sub Ouverture_Fichier()

    Set wApp = CreateObject("Word.Application")
    wApp.Visible = True
    'set wdoc=wapp.Documents.Open "<chemin d'access + nom du fichier>"
    ' autres instructions ...

    End Sub
    0
  2. tas6705
     
    Merci beaucoup ca marche nickel !
    0