J'ai une application Excel qui fait appel à Word, donc j'utilise
Word.Application
Mais avec Publisher ?
Parce que j'ai un problème de code si je veux remplacer "word" en
"publisher" :
Private Sub CommandButton3_Click()
Dim monApp As Publisher.Application
Dim lettre As Publisher.Document
Dim myRange As Range
Dim ref As String
Dim nomFic As String
Dim reponse1 As Integer
Dim reponse2 As Integer
Set myRange = Excel.Range("A1", "Y8")
g = 2
i = 2
reponse1 = MsgBox("Voulez vous videz ce tableux a la fin de
l'application ? ", 4)
reponse = MsgBox("Voulez vous (en plus de les créer) imprimer toutes ces
lettres maintenant?", 4, "IMPRESSION")
'on recupere la premiere ref courrier
firstRef = Cells(2, 17).Value
'tant que tout ouvrefic pas parcouru
Do While Not Cells(i, 2).Value = ""
firstRef = Cells(g, 17).Value
lastRef = Cells(i, 17).Value
'tant que meme ref courrier on passe a la ligne suivante
Do While firstRef = lastRef
i = i + 1
lastRef = Cells(i, 17).Value
Loop
'on ouvre la lettre type ref
Set monApp = New Publisher.Application
Set lettre = monApp.Documents("C:\PUBLIPOST\relance\" & firstRef &
".pub")
'on fusionne
With lettre.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource "C:\PUBLIPOST\ouvrefic2.xls", ReadOnly:=True,
Connection:="myRange"
'on selectionne que les ligne qui nous interresse
.DataSource.FirstRecord = g - 1
.DataSource.LastRecord = i - 2
.Destination = wdSendToNewDocument
.Execute pause:=True
'on sauve au nom de la lettre ref
.Application.ActiveDocument.SaveAs ("C:\PUBLIPOST\resultat\" &
firstRef & ".pub")
End With
With lettre.MailMerge
If reponse = 6 Then
.Application.ActiveDocument.PrintOut
End If
.Application.ActiveDocument.Close
End With
monApp.Documents.Close
g = i
Loop
MsgBox "Toute les relances ont été générées."
If reponse1 = 6 Then
'on vide ouvrefic
Range("A2", "Y" & i & "").Value = ""
MsgBox "Toutes les valeurs ont été supprimées."
End If
End Sub
Private Sub CommandButton4_Click()
'Tri automatique sur une colonne déterminée
Cells.Select
'Sélection sur la "Référence Courrier"
Selection.Sort Key1:=Range("Q2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
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
JLG
Bonjour
faite un essai en mettant MSPUB.Application
-- Antispam retirer "toto" de mon adresse E-mail
v wrote:
Bonjour,
J'ai une application Excel qui fait appel à Word, donc j'utilise Word.Application Mais avec Publisher ?
Parce que j'ai un problème de code si je veux remplacer "word" en "publisher" :
Private Sub CommandButton3_Click()
Dim monApp As Publisher.Application
Dim lettre As Publisher.Document
Dim myRange As Range Dim ref As String Dim nomFic As String Dim reponse1 As Integer Dim reponse2 As Integer Set myRange = Excel.Range("A1", "Y8") g = 2 i = 2 reponse1 = MsgBox("Voulez vous videz ce tableux a la fin de l'application ? ", 4) reponse = MsgBox("Voulez vous (en plus de les créer) imprimer toutes ces lettres maintenant?", 4, "IMPRESSION") 'on recupere la premiere ref courrier firstRef = Cells(2, 17).Value 'tant que tout ouvrefic pas parcouru Do While Not Cells(i, 2).Value = "" firstRef = Cells(g, 17).Value lastRef = Cells(i, 17).Value 'tant que meme ref courrier on passe a la ligne suivante Do While firstRef = lastRef i = i + 1 lastRef = Cells(i, 17).Value Loop 'on ouvre la lettre type ref Set monApp = New Publisher.Application Set lettre = monApp.Documents("C:PUBLIPOSTrelance" & firstRef & ".pub")
'on fusionne With lettre.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource "C:PUBLIPOSTouvrefic2.xls", ReadOnly:=True, Connection:="myRange" 'on selectionne que les ligne qui nous interresse .DataSource.FirstRecord = g - 1 .DataSource.LastRecord = i - 2 .Destination = wdSendToNewDocument .Execute pause:=True 'on sauve au nom de la lettre ref .Application.ActiveDocument.SaveAs ("C:PUBLIPOSTresultat" & firstRef & ".pub") End With With lettre.MailMerge If reponse = 6 Then .Application.ActiveDocument.PrintOut End If .Application.ActiveDocument.Close End With monApp.Documents.Close g = i Loop MsgBox "Toute les relances ont été générées." If reponse1 = 6 Then 'on vide ouvrefic Range("A2", "Y" & i & "").Value = "" MsgBox "Toutes les valeurs ont été supprimées." End If
End Sub
Private Sub CommandButton4_Click() 'Tri automatique sur une colonne déterminée
Cells.Select
'Sélection sur la "Référence Courrier" Selection.Sort Key1:=Range("Q2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal
'Information MsgBox "Opération terminée"
End Sub
Bonjour
faite un essai en mettant MSPUB.Application
--
Antispam
retirer "toto" de mon adresse E-mail
v wrote:
Bonjour,
J'ai une application Excel qui fait appel à Word, donc j'utilise
Word.Application
Mais avec Publisher ?
Parce que j'ai un problème de code si je veux remplacer "word" en
"publisher" :
Private Sub CommandButton3_Click()
Dim monApp As Publisher.Application
Dim lettre As Publisher.Document
Dim myRange As Range
Dim ref As String
Dim nomFic As String
Dim reponse1 As Integer
Dim reponse2 As Integer
Set myRange = Excel.Range("A1", "Y8")
g = 2
i = 2
reponse1 = MsgBox("Voulez vous videz ce tableux a la fin de
l'application ? ", 4)
reponse = MsgBox("Voulez vous (en plus de les créer) imprimer toutes
ces lettres maintenant?", 4, "IMPRESSION")
'on recupere la premiere ref courrier
firstRef = Cells(2, 17).Value
'tant que tout ouvrefic pas parcouru
Do While Not Cells(i, 2).Value = ""
firstRef = Cells(g, 17).Value
lastRef = Cells(i, 17).Value
'tant que meme ref courrier on passe a la ligne suivante
Do While firstRef = lastRef
i = i + 1
lastRef = Cells(i, 17).Value
Loop
'on ouvre la lettre type ref
Set monApp = New Publisher.Application
Set lettre = monApp.Documents("C:PUBLIPOSTrelance" & firstRef &
".pub")
'on fusionne
With lettre.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource "C:PUBLIPOSTouvrefic2.xls", ReadOnly:=True,
Connection:="myRange"
'on selectionne que les ligne qui nous interresse
.DataSource.FirstRecord = g - 1
.DataSource.LastRecord = i - 2
.Destination = wdSendToNewDocument
.Execute pause:=True
'on sauve au nom de la lettre ref
.Application.ActiveDocument.SaveAs ("C:PUBLIPOSTresultat" &
firstRef & ".pub")
End With
With lettre.MailMerge
If reponse = 6 Then
.Application.ActiveDocument.PrintOut
End If
.Application.ActiveDocument.Close
End With
monApp.Documents.Close
g = i
Loop
MsgBox "Toute les relances ont été générées."
If reponse1 = 6 Then
'on vide ouvrefic
Range("A2", "Y" & i & "").Value = ""
MsgBox "Toutes les valeurs ont été supprimées."
End If
End Sub
Private Sub CommandButton4_Click()
'Tri automatique sur une colonne déterminée
Cells.Select
'Sélection sur la "Référence Courrier"
Selection.Sort Key1:=Range("Q2"), Order1:=xlAscending,
Header:=xlGuess, _ OrderCustom:=1, MatchCase:úlse,
Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal
J'ai une application Excel qui fait appel à Word, donc j'utilise Word.Application Mais avec Publisher ?
Parce que j'ai un problème de code si je veux remplacer "word" en "publisher" :
Private Sub CommandButton3_Click()
Dim monApp As Publisher.Application
Dim lettre As Publisher.Document
Dim myRange As Range Dim ref As String Dim nomFic As String Dim reponse1 As Integer Dim reponse2 As Integer Set myRange = Excel.Range("A1", "Y8") g = 2 i = 2 reponse1 = MsgBox("Voulez vous videz ce tableux a la fin de l'application ? ", 4) reponse = MsgBox("Voulez vous (en plus de les créer) imprimer toutes ces lettres maintenant?", 4, "IMPRESSION") 'on recupere la premiere ref courrier firstRef = Cells(2, 17).Value 'tant que tout ouvrefic pas parcouru Do While Not Cells(i, 2).Value = "" firstRef = Cells(g, 17).Value lastRef = Cells(i, 17).Value 'tant que meme ref courrier on passe a la ligne suivante Do While firstRef = lastRef i = i + 1 lastRef = Cells(i, 17).Value Loop 'on ouvre la lettre type ref Set monApp = New Publisher.Application Set lettre = monApp.Documents("C:PUBLIPOSTrelance" & firstRef & ".pub")
'on fusionne With lettre.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource "C:PUBLIPOSTouvrefic2.xls", ReadOnly:=True, Connection:="myRange" 'on selectionne que les ligne qui nous interresse .DataSource.FirstRecord = g - 1 .DataSource.LastRecord = i - 2 .Destination = wdSendToNewDocument .Execute pause:=True 'on sauve au nom de la lettre ref .Application.ActiveDocument.SaveAs ("C:PUBLIPOSTresultat" & firstRef & ".pub") End With With lettre.MailMerge If reponse = 6 Then .Application.ActiveDocument.PrintOut End If .Application.ActiveDocument.Close End With monApp.Documents.Close g = i Loop MsgBox "Toute les relances ont été générées." If reponse1 = 6 Then 'on vide ouvrefic Range("A2", "Y" & i & "").Value = "" MsgBox "Toutes les valeurs ont été supprimées." End If
End Sub
Private Sub CommandButton4_Click() 'Tri automatique sur une colonne déterminée
Cells.Select
'Sélection sur la "Référence Courrier" Selection.Sort Key1:=Range("Q2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal
'Information MsgBox "Opération terminée"
End Sub
JLG
Faire un essai avec MSPUB.Application sinon, voir sur le forum Excel
-- Antispam retirer "toto" de mon adresse E-mail
v wrote:
Bonjour,
J'ai une application Excel qui fait appel à Word, donc j'utilise Word.Application Mais avec Publisher ?
Parce que j'ai un problème de code si je veux remplacer "word" en "publisher" :
Private Sub CommandButton3_Click()
Dim monApp As Publisher.Application
Dim lettre As Publisher.Document
Dim myRange As Range Dim ref As String Dim nomFic As String Dim reponse1 As Integer Dim reponse2 As Integer Set myRange = Excel.Range("A1", "Y8") g = 2 i = 2 reponse1 = MsgBox("Voulez vous videz ce tableux a la fin de l'application ? ", 4) reponse = MsgBox("Voulez vous (en plus de les créer) imprimer toutes ces lettres maintenant?", 4, "IMPRESSION") 'on recupere la premiere ref courrier firstRef = Cells(2, 17).Value 'tant que tout ouvrefic pas parcouru Do While Not Cells(i, 2).Value = "" firstRef = Cells(g, 17).Value lastRef = Cells(i, 17).Value 'tant que meme ref courrier on passe a la ligne suivante Do While firstRef = lastRef i = i + 1 lastRef = Cells(i, 17).Value Loop 'on ouvre la lettre type ref Set monApp = New Publisher.Application Set lettre = monApp.Documents("C:PUBLIPOSTrelance" & firstRef & ".pub")
'on fusionne With lettre.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource "C:PUBLIPOSTouvrefic2.xls", ReadOnly:=True, Connection:="myRange" 'on selectionne que les ligne qui nous interresse .DataSource.FirstRecord = g - 1 .DataSource.LastRecord = i - 2 .Destination = wdSendToNewDocument .Execute pause:=True 'on sauve au nom de la lettre ref .Application.ActiveDocument.SaveAs ("C:PUBLIPOSTresultat" & firstRef & ".pub") End With With lettre.MailMerge If reponse = 6 Then .Application.ActiveDocument.PrintOut End If .Application.ActiveDocument.Close End With monApp.Documents.Close g = i Loop MsgBox "Toute les relances ont été générées." If reponse1 = 6 Then 'on vide ouvrefic Range("A2", "Y" & i & "").Value = "" MsgBox "Toutes les valeurs ont été supprimées." End If
End Sub
Private Sub CommandButton4_Click() 'Tri automatique sur une colonne déterminée
Cells.Select
'Sélection sur la "Référence Courrier" Selection.Sort Key1:=Range("Q2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal
'Information MsgBox "Opération terminée"
End Sub
Faire un essai avec MSPUB.Application
sinon, voir sur le forum Excel
--
Antispam
retirer "toto" de mon adresse E-mail
v wrote:
Bonjour,
J'ai une application Excel qui fait appel à Word, donc j'utilise
Word.Application
Mais avec Publisher ?
Parce que j'ai un problème de code si je veux remplacer "word" en
"publisher" :
Private Sub CommandButton3_Click()
Dim monApp As Publisher.Application
Dim lettre As Publisher.Document
Dim myRange As Range
Dim ref As String
Dim nomFic As String
Dim reponse1 As Integer
Dim reponse2 As Integer
Set myRange = Excel.Range("A1", "Y8")
g = 2
i = 2
reponse1 = MsgBox("Voulez vous videz ce tableux a la fin de
l'application ? ", 4)
reponse = MsgBox("Voulez vous (en plus de les créer) imprimer toutes
ces lettres maintenant?", 4, "IMPRESSION")
'on recupere la premiere ref courrier
firstRef = Cells(2, 17).Value
'tant que tout ouvrefic pas parcouru
Do While Not Cells(i, 2).Value = ""
firstRef = Cells(g, 17).Value
lastRef = Cells(i, 17).Value
'tant que meme ref courrier on passe a la ligne suivante
Do While firstRef = lastRef
i = i + 1
lastRef = Cells(i, 17).Value
Loop
'on ouvre la lettre type ref
Set monApp = New Publisher.Application
Set lettre = monApp.Documents("C:PUBLIPOSTrelance" & firstRef &
".pub")
'on fusionne
With lettre.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource "C:PUBLIPOSTouvrefic2.xls", ReadOnly:=True,
Connection:="myRange"
'on selectionne que les ligne qui nous interresse
.DataSource.FirstRecord = g - 1
.DataSource.LastRecord = i - 2
.Destination = wdSendToNewDocument
.Execute pause:=True
'on sauve au nom de la lettre ref
.Application.ActiveDocument.SaveAs ("C:PUBLIPOSTresultat" &
firstRef & ".pub")
End With
With lettre.MailMerge
If reponse = 6 Then
.Application.ActiveDocument.PrintOut
End If
.Application.ActiveDocument.Close
End With
monApp.Documents.Close
g = i
Loop
MsgBox "Toute les relances ont été générées."
If reponse1 = 6 Then
'on vide ouvrefic
Range("A2", "Y" & i & "").Value = ""
MsgBox "Toutes les valeurs ont été supprimées."
End If
End Sub
Private Sub CommandButton4_Click()
'Tri automatique sur une colonne déterminée
Cells.Select
'Sélection sur la "Référence Courrier"
Selection.Sort Key1:=Range("Q2"), Order1:=xlAscending,
Header:=xlGuess, _ OrderCustom:=1, MatchCase:úlse,
Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal
Faire un essai avec MSPUB.Application sinon, voir sur le forum Excel
-- Antispam retirer "toto" de mon adresse E-mail
v wrote:
Bonjour,
J'ai une application Excel qui fait appel à Word, donc j'utilise Word.Application Mais avec Publisher ?
Parce que j'ai un problème de code si je veux remplacer "word" en "publisher" :
Private Sub CommandButton3_Click()
Dim monApp As Publisher.Application
Dim lettre As Publisher.Document
Dim myRange As Range Dim ref As String Dim nomFic As String Dim reponse1 As Integer Dim reponse2 As Integer Set myRange = Excel.Range("A1", "Y8") g = 2 i = 2 reponse1 = MsgBox("Voulez vous videz ce tableux a la fin de l'application ? ", 4) reponse = MsgBox("Voulez vous (en plus de les créer) imprimer toutes ces lettres maintenant?", 4, "IMPRESSION") 'on recupere la premiere ref courrier firstRef = Cells(2, 17).Value 'tant que tout ouvrefic pas parcouru Do While Not Cells(i, 2).Value = "" firstRef = Cells(g, 17).Value lastRef = Cells(i, 17).Value 'tant que meme ref courrier on passe a la ligne suivante Do While firstRef = lastRef i = i + 1 lastRef = Cells(i, 17).Value Loop 'on ouvre la lettre type ref Set monApp = New Publisher.Application Set lettre = monApp.Documents("C:PUBLIPOSTrelance" & firstRef & ".pub")
'on fusionne With lettre.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource "C:PUBLIPOSTouvrefic2.xls", ReadOnly:=True, Connection:="myRange" 'on selectionne que les ligne qui nous interresse .DataSource.FirstRecord = g - 1 .DataSource.LastRecord = i - 2 .Destination = wdSendToNewDocument .Execute pause:=True 'on sauve au nom de la lettre ref .Application.ActiveDocument.SaveAs ("C:PUBLIPOSTresultat" & firstRef & ".pub") End With With lettre.MailMerge If reponse = 6 Then .Application.ActiveDocument.PrintOut End If .Application.ActiveDocument.Close End With monApp.Documents.Close g = i Loop MsgBox "Toute les relances ont été générées." If reponse1 = 6 Then 'on vide ouvrefic Range("A2", "Y" & i & "").Value = "" MsgBox "Toutes les valeurs ont été supprimées." End If
End Sub
Private Sub CommandButton4_Click() 'Tri automatique sur une colonne déterminée
Cells.Select
'Sélection sur la "Référence Courrier" Selection.Sort Key1:=Range("Q2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:úlse, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal
'Information MsgBox "Opération terminée"
End Sub
v
JLG a écrit :
Faire un essai avec MSPUB.Application sinon, voir sur le forum Excel
Ca ne marche pas
On peut vraiment ouvrir un fichier .pub dans un code VBA se trouvant sur Excel ?
JLG a écrit :
Faire un essai avec MSPUB.Application
sinon, voir sur le forum Excel
Ca ne marche pas
On peut vraiment ouvrir un fichier .pub dans un code VBA se trouvant sur
Excel ?
Faire un essai avec MSPUB.Application sinon, voir sur le forum Excel
Ca ne marche pas
On peut vraiment ouvrir un fichier .pub dans un code VBA se trouvant sur Excel ?
Clément Marcotte
Bonjour,
Il l'a déjà fait. Il voudrait prendre une macro qu'il a déjà pour Word, changer Word pour Publisher à 2 ou 3 places et faire un publitostage dans Publisher avec cela.
Pourtant je luis ai dit que les modèles d'objets étaient différents. Pour l'instant, je n'ai pas le temps, de tout refaire sa macro dans Publisher.
"JLG" a écrit dans le message de news: uyU$
je ne sais pas;, le mieux est de poser la question sur le forum Excel
Faire un essai avec MSPUB.Application sinon, voir sur le forum Excel
Ca ne marche pas
On peut vraiment ouvrir un fichier .pub dans un code VBA se trouvant sur Excel ?
Bonjour,
Il l'a déjà fait. Il voudrait prendre une macro qu'il a déjà pour Word,
changer Word pour Publisher à 2 ou 3 places et faire un publitostage dans
Publisher avec cela.
Pourtant je luis ai dit que les modèles d'objets étaient différents. Pour
l'instant, je n'ai pas le temps, de tout refaire sa macro dans Publisher.
"JLG" <totojlgarotin@wanadoo.fr> a écrit dans le message de news:
uyU$VCaIGHA.216@TK2MSFTNGP15.phx.gbl...
je ne sais pas;, le mieux est de poser la question sur le forum Excel
Il l'a déjà fait. Il voudrait prendre une macro qu'il a déjà pour Word, changer Word pour Publisher à 2 ou 3 places et faire un publitostage dans Publisher avec cela.
Pourtant je luis ai dit que les modèles d'objets étaient différents. Pour l'instant, je n'ai pas le temps, de tout refaire sa macro dans Publisher.
"JLG" a écrit dans le message de news: uyU$
je ne sais pas;, le mieux est de poser la question sur le forum Excel