By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,234 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,234 IT Pros & Developers. It's quick & easy.

automation Template word by VB.net

P: 1
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.Office.Interop.Word
Public Class Form1

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
  2. Dim wdApp As Word.Application = New Word.Application() 
  3. wdApp.Visible = True 
  4.  
  5. 'L'adresse entre griffes est celle du fichier .dotx qui sera modifié 
  6. Dim wdDoc As Word.Document = wdApp.Documents.Add("F:\Hippolyte\Desktop\Hippolyte\Desktop\NewFolder\baseTemplate2.dotx") 
  7.  
  8. 'Text1 est le nom du signet qui sera remplacé dans le fichier .dotx . 
  9. wdDoc.Bookmarks("Text1").Range.Text = nameTextBox.Text 
  10.  
  11. wdDoc = Nothing 
  12. wdApp = Nothing 
  13. GC.Collect() 
  14. GC.WaitForPendingFinalizers() 
  15. GC.Collect() 
  16. GC.WaitForPendingFinalizers() 
  17. End Sub 
  18.  
  19. 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
Mar 22 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.