automation Template word by VB.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • asmatopo
    New Member
    • Mar 2013
    • 1

    automation Template word by VB.net

    hello all,

    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.Offic e.Interop.Word
    Public Class Form1

    Code:
    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
    I have too problemes: the first, Im using chekedlistbox to insert names in a word template, im' using the following code but it only inserts the last ITEM on the list. I want to write each word is in a line with puces like:
    -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
Working...