Ouvrir word et ajouter un pied de page

keunene Messages postés 72 Date d'inscription samedi 5 avril 2014 Statut Membre Dernière intervention 10 mars 2023 - 5 nov. 2014 à 10:47
keunene Messages postés 72 Date d'inscription samedi 5 avril 2014 Statut Membre Dernière intervention 10 mars 2023 - 6 nov. 2014 à 12:54
bonjour,
je voudrais faire un pied de page mais je n'y arrive pas.
ce que mon code me donne c'est une note de page en bas.
voici mon code:

Dim piedpage As Word.Footnote
Try

'oTable.Range.InsertParagraphAfter()
piedpage = oDoc.Footnotes.Add(oDoc.Bookmarks.Item("\endofdoc").Range)
piedpage.Range.Text = "Inspection Générale des Finances, Abidjan Plateau, Boulevard Angoulvant, 19 Clozel à l'angle, Avenue A58 Docteur" + vbCrLf + _
" Adresse postale : 04 BP 2876 Abidjan 04 Téléphone : 20 22 51 56 / 20 21 60 16 Fax : 20 21 10 80"
piedpage.Range.Font.Bold = True
piedpage.Range.Font.Italic = True
piedpage.Range.Font.Size = 9

Catch
End Try

merci pour votre assistance

3 réponses

ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
5 nov. 2014 à 17:25
Bonjour,

1) Sais-tu le faire depuis Word/VBA directement ? (car à savoir avant même de tenter de le faire en "pilotage"). Si non : question à poser dans la section VBA, mais après avoir lu ceci :
http://msdn.microsoft.com/en-us/library/office/ff838736%28v=office.15%29.aspx

2) on ne voit même pas où et comment tu as créé l'objet odoc




0
keunene Messages postés 72 Date d'inscription samedi 5 avril 2014 Statut Membre Dernière intervention 10 mars 2023
6 nov. 2014 à 11:44
Merci à tous.j'ai fait des recherches sur le site de microsoft et j'ai trouvé une réponse.
pour que ce code fonctionne, il faut d'abord aller dans le menu de visual studio(moi j'ai le 12) - projet- ajouter une reférence- une sorte de menu contextuel s'ouvre ;appuyez sur COM et cochez " [B][I][U]MIcrosoft word 12.0 object library/U/I/B" (pour certains le 12.0 peut être 14.0 ou autre.je l'ai même testé avec word 2007 ça marche parfaitement maispas proprement avec WORD 2010
Imports Word = Microsoft.Office.Interop.Word

Public Class historic



'note
Private Sub PublipostageNoteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles PublipostageNoteToolStripMenuItem.Click
Dim oWord As Word.Application
Dim oDoc As Word.Document

Dim oPara1 As Word.Paragraph, oPara2 As Word.Paragraph


'Start Word and open the document template.
oWord = CreateObject("Word.Application")
oWord.Visible = True
oDoc = oWord.Documents.Add
Try
'Insertion de paragraphes.
oPara1 = oDoc.Content.Paragraphs.Add
oPara1.Range.Text = "MINISTERE AUPRES DU PREMIER MINISTRE "
oPara1.Range.Font.Bold = True
oPara1.Format.SpaceAfter = 2 '4 pt spacing after paragraph.
oPara1.Range.InsertParagraphAfter()

pied de page
Try
oDoc.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True
'ce Footers en gras vous pouvez le changer en Headers et il de vient un haut de page
With oDoc.Sections(1).[B]Footers/B(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).Range

.Text = " Inspection Générale des Finances, Abidjan Plateau, Boulevard Angoulvant, 19 Clozel à l'angle, Avenue A58 Docteur" + vbCrLf + _
" Adresse postale : 04 BP 2876 Abidjan 04 Téléphone : 20 22 51 56 / 20 21 60 16 Fax : 20 21 10 80"
.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
.Font.Size = 9

.InlineShapes.AddHorizontalLineStandard()
End With

Catch ex As Exception
MsgBox(ex.ToString)
End Try



End Sub

End Class

pour les notes de pages vous pouvez voir le premier post en haut
0
keunene Messages postés 72 Date d'inscription samedi 5 avril 2014 Statut Membre Dernière intervention 10 mars 2023
6 nov. 2014 à 12:54
 Imports Word = Microsoft.Office.Interop.Word

Public Class historic



'note
Private Sub PublipostageNoteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles PublipostageNoteToolStripMenuItem.Click
Dim oWord As Word.Application
Dim oDoc As Word.Document

Dim oPara1 As Word.Paragraph, oPara2 As Word.Paragraph


'Start Word and open the document template.
oWord = CreateObject("Word.Application")
oWord.Visible = True
oDoc = oWord.Documents.Add
Try
'Insertion de paragraphes.
oPara1 = oDoc.Content.Paragraphs.Add
oPara1.Range.Text = "MINISTERE AUPRES DU PREMIER MINISTRE "
oPara1.Range.Font.Bold = True
oPara1.Format.SpaceAfter = 2 '4 pt spacing after paragraph.
oPara1.Range.InsertParagraphAfter()

Catch ex As Exception
MsgBox(ex.ToString)
End Try
' pied de page
Try
oDoc.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True
'ce Footers en gras vous pouvez le changer en Headers et il de vient un haut de page
With oDoc.Sections(1).Footers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).Range

.Text = " Inspection Générale des Finances, Abidjan Plateau, Boulevard Angoulvant, 19 Clozel à l'angle, Avenue A58 Docteur" + vbCrLf + _
" Adresse postale : 04 BP 2876 Abidjan 04 Téléphone : 20 22 51 56 / 20 21 60 16 Fax : 20 21 10 80"
.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
.Font.Size = 9

.InlineShapes.AddHorizontalLineStandard()
End With

Catch ex As Exception
MsgBox(ex.ToString)
End Try



End Sub

End Class

je reprends cela car j'ai fait quelques erreurs en copiant et en collant
0
cs_ShayW Messages postés 3253 Date d'inscription jeudi 26 novembre 2009 Statut Membre Dernière intervention 3 décembre 2019 57
6 nov. 2014 à 11:59
Bonjour
Comme avait dit Ucfoutu
2) on ne voit même pas où et comment tu as créé l'objet odoc
0
Rejoignez-nous