Access-Word Copie de lignes

Résolu
aaliyan Messages postés 104 Date d'inscription samedi 12 mars 2005 Statut Membre Dernière intervention 30 avril 2007 - 13 avril 2007 à 10:03
aaliyan Messages postés 104 Date d'inscription samedi 12 mars 2005 Statut Membre Dernière intervention 30 avril 2007 - 13 avril 2007 à 11:27
Bonjour, je voudrais, sous access en lancant une macro, copier une  seule ligne jusqu'à la fin à partir d'un signet dans un fichier Word. Voilà le début de mon code :

  Fichier = rs.Fields("titre")
  
 Chemin = "C:" & Fichier & ".doc"
 
  Set Wd = CreateObject("Word.Application")
  With Wd
      .Visible = True
      .Documents.Open Chemin
      .Activate
  End With

  Set MyDoc = Wd.ActiveDocument
  If MyDoc.Bookmarks.Exists("Nom") = True Then
     MyDoc.Bookmarks("Nom").Select
  End If

Je me place sur le signet. Et là, je bloque, je veux copier la igne jusqu'au saut de ligne. Merci pour votre aide.

4 réponses

aaliyan Messages postés 104 Date d'inscription samedi 12 mars 2005 Statut Membre Dernière intervention 30 avril 2007
13 avril 2007 à 11:27
J'ai trouvé la réponse :

  Fichier = rs.Fields("titre")
 
  Chemin = "C:" & Fichier & ".doc"
 
  Set Wd = CreateObject("Word.Application")
  With Wd
      .Visible = True
      .Documents.Open Chemin
      .Activate
  End With
 


 
  'remplissage nom
  If Wd.ActiveDocument.Bookmarks.Exists("Nom") = True Then
    Wd.ActiveDocument.Bookmarks("Nom").Select
  End If
  Call Wd.Selection.MoveDown(wdLine, 1, wdExtend)
  Call Wd.Selection.MoveLeft(wdCharacter, 2, wdExtend)
  Selection.Copy
  Forms!Recherche!fiche!dem = Selection
3
cs_loulou69 Messages postés 672 Date d'inscription mercredi 22 janvier 2003 Statut Membre Dernière intervention 2 juin 2016 1
13 avril 2007 à 10:09
Bonjour

Suite à la sélection du signet , étendre la sélection

With Selection
    .Expand Unit:=wdSentence
End With
0
aaliyan Messages postés 104 Date d'inscription samedi 12 mars 2005 Statut Membre Dernière intervention 30 avril 2007
13 avril 2007 à 10:24
  If MyDoc.Bookmarks.Exists("DateMaJ") = True Then
    MyDoc.Bookmarks("DateMaJ").Select
    With Selection
        .Expand Unit:=wdSentence
    End With
  End If

Cela plante.
0
aaliyan Messages postés 104 Date d'inscription samedi 12 mars 2005 Statut Membre Dernière intervention 30 avril 2007
13 avril 2007 à 11:27
J'ai trouvé la réponse :

  Fichier = rs.Fields("titre")
 
  Chemin = "C:" & Fichier & ".doc"
 
  Set Wd = CreateObject("Word.Application")
  With Wd
      .Visible = True
      .Documents.Open Chemin
      .Activate
  End With
 


 
  'remplissage nom
  If Wd.ActiveDocument.Bookmarks.Exists("Nom") = True Then
    Wd.ActiveDocument.Bookmarks("Nom").Select
  End If
  Call Wd.Selection.MoveDown(wdLine, 1, wdExtend)
  Call Wd.Selection.MoveLeft(wdCharacter, 2, wdExtend)
  Selection.Copy
  Forms!Recherche!fiche!dem = Selection
0
Rejoignez-nous