-1
我在VB.NET Visual Studio 2010中編寫應用程序。我的目標是將許多圖像從硬盤驅動器上的選定位置插入Word文檔,但每個圖像應與每個圖像分開其他由一行文字"picture no 1,2..."
等。我已經編寫了可以選擇一些圖片並將它們插入到doc文件中的程序,但圖像不是通過文本行分隔的。我不知道該怎麼做,所以我要求你的幫助。如何將圖像和文本插入到Word文檔中
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Dim oword As New Microsoft.Office.Interop.Word.Application()
Dim odoc As Word.Document
oword = CreateObject("Word.Application")
oword.Visible = True
odoc = oword.Documents.Add
Dim ofd As New OpenFileDialog()
ofd.Filter = "Images (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF"
ofd.Title = "Choose your images...."
ofd.Multiselect = True
If ofd.ShowDialog() = DialogResult.OK Then
For Each filename As String In ofd.FileNames
Dim oPara2, oPara3 As Word.Paragraph
oPara2 = odoc.Content.Paragraphs.Add
Dim map As InlineShape = odoc.InlineShapes.AddPicture _
(filename, Type.Missing, Type.Missing,Type.Missing)
map.Height = 350
map.Width = 350
oPara3 = odoc.Content.Paragraphs.Add
oPara3.Range.Font.Name = "Arial"
oPara3.Range.Font.Size = 14
oPara3.Range.Text = "Picture no "
Next
End If
End Sub
謝謝你的答案。現在正在工作。 – Suszi84
很高興聽到它:-)如果您有時間,如果您可以在「有幫助」的計數器下激活答案左側的「答覆選項」?這有助於SO網站管理人員和其他類似問題的用戶認識到問題有一個可用的答案。 –