Bonjour à tous,
Est-il possible de lancer WORD depuis une macro Excel et de copier des
données de l'un vers l'autre (d'Excel vers Word), sachant qu'il y a
plusieurs "copiages à faire" ?
Merci beaucoup,
Lulu
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
jb
Bonjour,
Voici un exemple de OLE automation Excel->Word. A partir d'une lettre type avec des signets, on crée des courriers personnalisés.
http://cjoint.com/?kFqA4O8AXN
http://cjoint.com/?kFqCl6LwD6
Cordialement JB
Sub ole() Dim oApp As Word.Application, doc As Word.Document Range("A2").Select ' premier client Do While Not IsEmpty(ActiveCell) On Error Resume Next nf = ThisWorkbook.Path & "malettre.doc" Set oApp = CreateObject("Word.Application") oApp.Visible = True Set doc = oApp.Documents.Open(nf) If Err <> 0 Then MsgBox "Le fichier malettre.doc doit être dans " & ThisWorkbook.Path Exit Sub End If On Error GoTo 0 ' Annule la gestion d'erreur '-- nom = ActiveCell.Value rue = ActiveCell.Offset(0, 1).Value ville = ActiveCell.Offset(0, 2).Value email = ActiveCell.Offset(0, 3).Value '-- With doc .Bookmarks("nom").Range.Text = nom .Bookmarks("rue").Range.Text = rue .Bookmarks("ville").Range.Text = ville End With nom_doc = ThisWorkbook.Path & "" & nom & ".doc" doc.SaveAs nom_doc oApp.Quit ActiveCell.Offset(1, 0).Select ' Client suivant Loop Set oApp = Nothing MsgBox "Lettres crées" End Sub
Bonjour,
Voici un exemple de OLE automation Excel->Word.
A partir d'une lettre type avec des signets, on crée des courriers
personnalisés.
http://cjoint.com/?kFqA4O8AXN
http://cjoint.com/?kFqCl6LwD6
Cordialement JB
Sub ole()
Dim oApp As Word.Application, doc As Word.Document
Range("A2").Select ' premier client
Do While Not IsEmpty(ActiveCell)
On Error Resume Next
nf = ThisWorkbook.Path & "malettre.doc"
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
Set doc = oApp.Documents.Open(nf)
If Err <> 0 Then
MsgBox "Le fichier malettre.doc doit être dans " &
ThisWorkbook.Path
Exit Sub
End If
On Error GoTo 0 ' Annule la gestion d'erreur
'--
nom = ActiveCell.Value
rue = ActiveCell.Offset(0, 1).Value
ville = ActiveCell.Offset(0, 2).Value
email = ActiveCell.Offset(0, 3).Value
'--
With doc
.Bookmarks("nom").Range.Text = nom
.Bookmarks("rue").Range.Text = rue
.Bookmarks("ville").Range.Text = ville
End With
nom_doc = ThisWorkbook.Path & "" & nom & ".doc"
doc.SaveAs nom_doc
oApp.Quit
ActiveCell.Offset(1, 0).Select ' Client suivant
Loop
Set oApp = Nothing
MsgBox "Lettres crées"
End Sub
Voici un exemple de OLE automation Excel->Word. A partir d'une lettre type avec des signets, on crée des courriers personnalisés.
http://cjoint.com/?kFqA4O8AXN
http://cjoint.com/?kFqCl6LwD6
Cordialement JB
Sub ole() Dim oApp As Word.Application, doc As Word.Document Range("A2").Select ' premier client Do While Not IsEmpty(ActiveCell) On Error Resume Next nf = ThisWorkbook.Path & "malettre.doc" Set oApp = CreateObject("Word.Application") oApp.Visible = True Set doc = oApp.Documents.Open(nf) If Err <> 0 Then MsgBox "Le fichier malettre.doc doit être dans " & ThisWorkbook.Path Exit Sub End If On Error GoTo 0 ' Annule la gestion d'erreur '-- nom = ActiveCell.Value rue = ActiveCell.Offset(0, 1).Value ville = ActiveCell.Offset(0, 2).Value email = ActiveCell.Offset(0, 3).Value '-- With doc .Bookmarks("nom").Range.Text = nom .Bookmarks("rue").Range.Text = rue .Bookmarks("ville").Range.Text = ville End With nom_doc = ThisWorkbook.Path & "" & nom & ".doc" doc.SaveAs nom_doc oApp.Quit ActiveCell.Offset(1, 0).Select ' Client suivant Loop Set oApp = Nothing MsgBox "Lettres crées" End Sub
Lulu la nantaise
Super cool, et quelle rapidité ! A bientôt, Lulu "jb" a écrit dans le message de news: Bonjour,
Voici un exemple de OLE automation Excel->Word. A partir d'une lettre type avec des signets, on crée des courriers personnalisés.
http://cjoint.com/?kFqA4O8AXN
http://cjoint.com/?kFqCl6LwD6
Cordialement JB
Sub ole() Dim oApp As Word.Application, doc As Word.Document Range("A2").Select ' premier client Do While Not IsEmpty(ActiveCell) On Error Resume Next nf = ThisWorkbook.Path & "malettre.doc" Set oApp = CreateObject("Word.Application") oApp.Visible = True Set doc = oApp.Documents.Open(nf) If Err <> 0 Then MsgBox "Le fichier malettre.doc doit être dans " & ThisWorkbook.Path Exit Sub End If On Error GoTo 0 ' Annule la gestion d'erreur '-- nom = ActiveCell.Value rue = ActiveCell.Offset(0, 1).Value ville = ActiveCell.Offset(0, 2).Value email = ActiveCell.Offset(0, 3).Value '-- With doc .Bookmarks("nom").Range.Text = nom .Bookmarks("rue").Range.Text = rue .Bookmarks("ville").Range.Text = ville End With nom_doc = ThisWorkbook.Path & "" & nom & ".doc" doc.SaveAs nom_doc oApp.Quit ActiveCell.Offset(1, 0).Select ' Client suivant Loop Set oApp = Nothing MsgBox "Lettres crées" End Sub
Super cool, et quelle rapidité !
A bientôt,
Lulu
"jb" <boisgontier@hotmail.com> a écrit dans le message de
news:1130772624.035471.151160@o13g2000cwo.googlegroups.com...
Bonjour,
Voici un exemple de OLE automation Excel->Word.
A partir d'une lettre type avec des signets, on crée des courriers
personnalisés.
http://cjoint.com/?kFqA4O8AXN
http://cjoint.com/?kFqCl6LwD6
Cordialement JB
Sub ole()
Dim oApp As Word.Application, doc As Word.Document
Range("A2").Select ' premier client
Do While Not IsEmpty(ActiveCell)
On Error Resume Next
nf = ThisWorkbook.Path & "malettre.doc"
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
Set doc = oApp.Documents.Open(nf)
If Err <> 0 Then
MsgBox "Le fichier malettre.doc doit être dans " &
ThisWorkbook.Path
Exit Sub
End If
On Error GoTo 0 ' Annule la gestion d'erreur
'--
nom = ActiveCell.Value
rue = ActiveCell.Offset(0, 1).Value
ville = ActiveCell.Offset(0, 2).Value
email = ActiveCell.Offset(0, 3).Value
'--
With doc
.Bookmarks("nom").Range.Text = nom
.Bookmarks("rue").Range.Text = rue
.Bookmarks("ville").Range.Text = ville
End With
nom_doc = ThisWorkbook.Path & "" & nom & ".doc"
doc.SaveAs nom_doc
oApp.Quit
ActiveCell.Offset(1, 0).Select ' Client suivant
Loop
Set oApp = Nothing
MsgBox "Lettres crées"
End Sub
Super cool, et quelle rapidité ! A bientôt, Lulu "jb" a écrit dans le message de news: Bonjour,
Voici un exemple de OLE automation Excel->Word. A partir d'une lettre type avec des signets, on crée des courriers personnalisés.
http://cjoint.com/?kFqA4O8AXN
http://cjoint.com/?kFqCl6LwD6
Cordialement JB
Sub ole() Dim oApp As Word.Application, doc As Word.Document Range("A2").Select ' premier client Do While Not IsEmpty(ActiveCell) On Error Resume Next nf = ThisWorkbook.Path & "malettre.doc" Set oApp = CreateObject("Word.Application") oApp.Visible = True Set doc = oApp.Documents.Open(nf) If Err <> 0 Then MsgBox "Le fichier malettre.doc doit être dans " & ThisWorkbook.Path Exit Sub End If On Error GoTo 0 ' Annule la gestion d'erreur '-- nom = ActiveCell.Value rue = ActiveCell.Offset(0, 1).Value ville = ActiveCell.Offset(0, 2).Value email = ActiveCell.Offset(0, 3).Value '-- With doc .Bookmarks("nom").Range.Text = nom .Bookmarks("rue").Range.Text = rue .Bookmarks("ville").Range.Text = ville End With nom_doc = ThisWorkbook.Path & "" & nom & ".doc" doc.SaveAs nom_doc oApp.Quit ActiveCell.Offset(1, 0).Select ' Client suivant Loop Set oApp = Nothing MsgBox "Lettres crées" End Sub
Lulu la nantaise
Encore une petite question, je ne parviens pas à coller ce que j'ai copier dans Word .... Peux-tu encore m'aider ? Merci beaucoup ... "Lulu la nantaise" a écrit dans le message de news:%
Super cool, et quelle rapidité ! A bientôt, Lulu "jb" a écrit dans le message de news: Bonjour,
Voici un exemple de OLE automation Excel->Word. A partir d'une lettre type avec des signets, on crée des courriers personnalisés.
http://cjoint.com/?kFqA4O8AXN
http://cjoint.com/?kFqCl6LwD6
Cordialement JB
Sub ole() Dim oApp As Word.Application, doc As Word.Document Range("A2").Select ' premier client Do While Not IsEmpty(ActiveCell) On Error Resume Next nf = ThisWorkbook.Path & "malettre.doc" Set oApp = CreateObject("Word.Application") oApp.Visible = True Set doc = oApp.Documents.Open(nf) If Err <> 0 Then MsgBox "Le fichier malettre.doc doit être dans " & ThisWorkbook.Path Exit Sub End If On Error GoTo 0 ' Annule la gestion d'erreur '-- nom = ActiveCell.Value rue = ActiveCell.Offset(0, 1).Value ville = ActiveCell.Offset(0, 2).Value email = ActiveCell.Offset(0, 3).Value '-- With doc .Bookmarks("nom").Range.Text = nom .Bookmarks("rue").Range.Text = rue .Bookmarks("ville").Range.Text = ville End With nom_doc = ThisWorkbook.Path & "" & nom & ".doc" doc.SaveAs nom_doc oApp.Quit ActiveCell.Offset(1, 0).Select ' Client suivant Loop Set oApp = Nothing MsgBox "Lettres crées" End Sub
Encore une petite question, je ne parviens pas à coller ce que j'ai copier
dans Word ....
Peux-tu encore m'aider ?
Merci beaucoup ...
"Lulu la nantaise" <je_suis_curieux@laposte.net> a écrit dans le message de
news:%23fA2sKj3FHA.3628@TK2MSFTNGP10.phx.gbl...
Super cool, et quelle rapidité !
A bientôt,
Lulu
"jb" <boisgontier@hotmail.com> a écrit dans le message de
news:1130772624.035471.151160@o13g2000cwo.googlegroups.com...
Bonjour,
Voici un exemple de OLE automation Excel->Word.
A partir d'une lettre type avec des signets, on crée des courriers
personnalisés.
http://cjoint.com/?kFqA4O8AXN
http://cjoint.com/?kFqCl6LwD6
Cordialement JB
Sub ole()
Dim oApp As Word.Application, doc As Word.Document
Range("A2").Select ' premier client
Do While Not IsEmpty(ActiveCell)
On Error Resume Next
nf = ThisWorkbook.Path & "malettre.doc"
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
Set doc = oApp.Documents.Open(nf)
If Err <> 0 Then
MsgBox "Le fichier malettre.doc doit être dans " &
ThisWorkbook.Path
Exit Sub
End If
On Error GoTo 0 ' Annule la gestion d'erreur
'--
nom = ActiveCell.Value
rue = ActiveCell.Offset(0, 1).Value
ville = ActiveCell.Offset(0, 2).Value
email = ActiveCell.Offset(0, 3).Value
'--
With doc
.Bookmarks("nom").Range.Text = nom
.Bookmarks("rue").Range.Text = rue
.Bookmarks("ville").Range.Text = ville
End With
nom_doc = ThisWorkbook.Path & "" & nom & ".doc"
doc.SaveAs nom_doc
oApp.Quit
ActiveCell.Offset(1, 0).Select ' Client suivant
Loop
Set oApp = Nothing
MsgBox "Lettres crées"
End Sub
Encore une petite question, je ne parviens pas à coller ce que j'ai copier dans Word .... Peux-tu encore m'aider ? Merci beaucoup ... "Lulu la nantaise" a écrit dans le message de news:%
Super cool, et quelle rapidité ! A bientôt, Lulu "jb" a écrit dans le message de news: Bonjour,
Voici un exemple de OLE automation Excel->Word. A partir d'une lettre type avec des signets, on crée des courriers personnalisés.
http://cjoint.com/?kFqA4O8AXN
http://cjoint.com/?kFqCl6LwD6
Cordialement JB
Sub ole() Dim oApp As Word.Application, doc As Word.Document Range("A2").Select ' premier client Do While Not IsEmpty(ActiveCell) On Error Resume Next nf = ThisWorkbook.Path & "malettre.doc" Set oApp = CreateObject("Word.Application") oApp.Visible = True Set doc = oApp.Documents.Open(nf) If Err <> 0 Then MsgBox "Le fichier malettre.doc doit être dans " & ThisWorkbook.Path Exit Sub End If On Error GoTo 0 ' Annule la gestion d'erreur '-- nom = ActiveCell.Value rue = ActiveCell.Offset(0, 1).Value ville = ActiveCell.Offset(0, 2).Value email = ActiveCell.Offset(0, 3).Value '-- With doc .Bookmarks("nom").Range.Text = nom .Bookmarks("rue").Range.Text = rue .Bookmarks("ville").Range.Text = ville End With nom_doc = ThisWorkbook.Path & "" & nom & ".doc" doc.SaveAs nom_doc oApp.Quit ActiveCell.Offset(1, 0).Select ' Client suivant Loop Set oApp = Nothing MsgBox "Lettres crées" End Sub
Lulu la nantaise
Excuse pour la deuxième intervention, c'était une erreur qui n'avait rien à voir .... Merci encore ça marche du feu de Dieu ! Lulu
"Lulu la nantaise" a écrit dans le message de news:
Encore une petite question, je ne parviens pas à coller ce que j'ai copier dans Word .... Peux-tu encore m'aider ? Merci beaucoup ... "Lulu la nantaise" a écrit dans le message de
news:%
Super cool, et quelle rapidité ! A bientôt, Lulu "jb" a écrit dans le message de news: Bonjour,
Voici un exemple de OLE automation Excel->Word. A partir d'une lettre type avec des signets, on crée des courriers personnalisés.
http://cjoint.com/?kFqA4O8AXN
http://cjoint.com/?kFqCl6LwD6
Cordialement JB
Sub ole() Dim oApp As Word.Application, doc As Word.Document Range("A2").Select ' premier client Do While Not IsEmpty(ActiveCell) On Error Resume Next nf = ThisWorkbook.Path & "malettre.doc" Set oApp = CreateObject("Word.Application") oApp.Visible = True Set doc = oApp.Documents.Open(nf) If Err <> 0 Then MsgBox "Le fichier malettre.doc doit être dans " & ThisWorkbook.Path Exit Sub End If On Error GoTo 0 ' Annule la gestion d'erreur '-- nom = ActiveCell.Value rue = ActiveCell.Offset(0, 1).Value ville = ActiveCell.Offset(0, 2).Value email = ActiveCell.Offset(0, 3).Value '-- With doc .Bookmarks("nom").Range.Text = nom .Bookmarks("rue").Range.Text = rue .Bookmarks("ville").Range.Text = ville End With nom_doc = ThisWorkbook.Path & "" & nom & ".doc" doc.SaveAs nom_doc oApp.Quit ActiveCell.Offset(1, 0).Select ' Client suivant Loop Set oApp = Nothing MsgBox "Lettres crées" End Sub
Excuse pour la deuxième intervention, c'était une erreur qui n'avait rien à
voir ....
Merci encore ça marche du feu de Dieu !
Lulu
"Lulu la nantaise" <je_suis_curieux@laposte.net> a écrit dans le message de
news:OEq6yxk3FHA.2196@tk2msftngp13.phx.gbl...
Encore une petite question, je ne parviens pas à coller ce que j'ai copier
dans Word ....
Peux-tu encore m'aider ?
Merci beaucoup ...
"Lulu la nantaise" <je_suis_curieux@laposte.net> a écrit dans le message
de
news:%23fA2sKj3FHA.3628@TK2MSFTNGP10.phx.gbl...
Super cool, et quelle rapidité !
A bientôt,
Lulu
"jb" <boisgontier@hotmail.com> a écrit dans le message de
news:1130772624.035471.151160@o13g2000cwo.googlegroups.com...
Bonjour,
Voici un exemple de OLE automation Excel->Word.
A partir d'une lettre type avec des signets, on crée des courriers
personnalisés.
http://cjoint.com/?kFqA4O8AXN
http://cjoint.com/?kFqCl6LwD6
Cordialement JB
Sub ole()
Dim oApp As Word.Application, doc As Word.Document
Range("A2").Select ' premier client
Do While Not IsEmpty(ActiveCell)
On Error Resume Next
nf = ThisWorkbook.Path & "malettre.doc"
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
Set doc = oApp.Documents.Open(nf)
If Err <> 0 Then
MsgBox "Le fichier malettre.doc doit être dans " &
ThisWorkbook.Path
Exit Sub
End If
On Error GoTo 0 ' Annule la gestion d'erreur
'--
nom = ActiveCell.Value
rue = ActiveCell.Offset(0, 1).Value
ville = ActiveCell.Offset(0, 2).Value
email = ActiveCell.Offset(0, 3).Value
'--
With doc
.Bookmarks("nom").Range.Text = nom
.Bookmarks("rue").Range.Text = rue
.Bookmarks("ville").Range.Text = ville
End With
nom_doc = ThisWorkbook.Path & "" & nom & ".doc"
doc.SaveAs nom_doc
oApp.Quit
ActiveCell.Offset(1, 0).Select ' Client suivant
Loop
Set oApp = Nothing
MsgBox "Lettres crées"
End Sub
Excuse pour la deuxième intervention, c'était une erreur qui n'avait rien à voir .... Merci encore ça marche du feu de Dieu ! Lulu
"Lulu la nantaise" a écrit dans le message de news:
Encore une petite question, je ne parviens pas à coller ce que j'ai copier dans Word .... Peux-tu encore m'aider ? Merci beaucoup ... "Lulu la nantaise" a écrit dans le message de
news:%
Super cool, et quelle rapidité ! A bientôt, Lulu "jb" a écrit dans le message de news: Bonjour,
Voici un exemple de OLE automation Excel->Word. A partir d'une lettre type avec des signets, on crée des courriers personnalisés.
http://cjoint.com/?kFqA4O8AXN
http://cjoint.com/?kFqCl6LwD6
Cordialement JB
Sub ole() Dim oApp As Word.Application, doc As Word.Document Range("A2").Select ' premier client Do While Not IsEmpty(ActiveCell) On Error Resume Next nf = ThisWorkbook.Path & "malettre.doc" Set oApp = CreateObject("Word.Application") oApp.Visible = True Set doc = oApp.Documents.Open(nf) If Err <> 0 Then MsgBox "Le fichier malettre.doc doit être dans " & ThisWorkbook.Path Exit Sub End If On Error GoTo 0 ' Annule la gestion d'erreur '-- nom = ActiveCell.Value rue = ActiveCell.Offset(0, 1).Value ville = ActiveCell.Offset(0, 2).Value email = ActiveCell.Offset(0, 3).Value '-- With doc .Bookmarks("nom").Range.Text = nom .Bookmarks("rue").Range.Text = rue .Bookmarks("ville").Range.Text = ville End With nom_doc = ThisWorkbook.Path & "" & nom & ".doc" doc.SaveAs nom_doc oApp.Quit ActiveCell.Offset(1, 0).Select ' Client suivant Loop Set oApp = Nothing MsgBox "Lettres crées" End Sub