How to put a picture in Word table,but getting the names of picture from listbox. I have visual

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Imports Word = Microsoft.Office.Interop.Word<br/>
Public Class Form1<br/>
<br/>
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load<br/>
Dim a As String = My.Resources.picture<br/>
Dim b As String() = a.Split(vbNewLine)<br/>
ListBox1.Items.AddRange(b)<br/>
End Sub<br/>
<br/>
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click<br/>
Dim i As Integer = ListBox1.SelectedIndex<br/>
<br/>
If i = -1 Then<br/>
Exit Sub<br/>
End If<br/>
Dim n, m As Integer<br/>
n = ListBox2.Items.Count<br/>
m = n + 1<br/>
ListBox2.Items.Add(m & "." & " " & ListBox1.Items(i))<br/>
End Sub<br/>
<br/>
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click<br/>
Dim WordApp As Word.Application = CreateObject("Word.Application")<br/>
TextBox1.Text = ListBox2.Items.Count<br/>
Novi word dokument<br/>
Dim WordDoc As Word.Document = WordApp.Documents.Add()<br/>
WordApp.Visible = True<br/>
<br/>
Podesavanje velicine papira u ovom slucaju A4<br/>
WordDoc.PageSetup.PaperSize = Word.WdPaperSize.wdPaperA4<br/>
<br/>
<br/>
Podesavanje margina<br/>
WordDoc.PageSetup.LeftMargin = WordApp.MillimetersToPoints(10)<br/>
WordDoc.PageSetup.RightMargin = WordApp.MillimetersToPoints(10)<br/>
WordDoc.PageSetup.BottomMargin = WordApp.MillimetersToPoints(15)<br/>
WordDoc.PageSetup.TopMargin = WordApp.MillimetersToPoints(5)<br/>
<br/>
<br/>
Dim Tabela1 As Word.Table = WordDoc.Tables.Add(WordDoc.Bookmarks.Item("endofdoc").Range, TextBox1.Text, 3)<br/>
Tabela1.Range.ParagraphFormat.SpaceAfter = 0<br/>
<br/>
<br/>
For x As Integer = 0 To ListBox2.Items.Count - 1<br/>
Dim Line = From a In ListBox2.Items(x).ToString.Split(" "c) Select a.Replace(Chr(10), "")<br/>
If Line.Count = 2 Then<br/>
Tabela1.Cell(x + 1, 1).Range.Text = Line(0)<br/>
Tabela1.Cell(x + 1, 2).Range.Text = Line(1)<br/>
End If<br/>
next<br/>
With Tabela1<br/>
.Style = "Table Grid"<br/>
End With<br/>
End Sub<br/>
<br/>
End Class<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
I wont this in table.cell (3), from listbox2
<img src="http://social.microsoft.com/Forums/getfile/48057/" alt="

View the full article
 
Back
Top