I want to create an application in vb.net and I would pre-fill some part of a word template (date, name, tables, pictures) through my application.
I used the following code:
Imports Word = Microsoft.Office.Interop.Word
Public Class Form1
Expand|Select|Wrap|Line Numbers
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim wdApp As Word.Application = New Word.Application()
- wdApp.Visible = True
- 'L'adresse entre griffes est celle du fichier .dotx qui sera modifié
- Dim wdDoc As Word.Document = wdApp.Documents.Add("F:\Hippolyte\Desktop\Hippolyte\Desktop\NewFolder\baseTemplate2.dotx")
- 'Text1 est le nom du signet qui sera remplacé dans le fichier .dotx .
- wdDoc.Bookmarks("Text1").Range.Text = nameTextBox.Text
- wdDoc = Nothing
- wdApp = Nothing
- GC.Collect()
- GC.WaitForPendingFinalizers()
- GC.Collect()
- GC.WaitForPendingFinalizers()
- End Sub
- End Class
-asmae bethaoui
-mariam nejjar
-...
the second problem: I don't know the code that will allow me to fill tables and insert pictures in my word template.
My thanks in advance