Public Sub Textbox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
Dim p As String = InputBox("請輸入")
Dim WDAPP As Object
WDAPP = CreateObject("Word.Application")
WDAPP.Documents.Add(TextBox1.Text)
WDAPP.Selection.Find.ClearFormatting()
With WDAPP.Selection.Find.Text = p
Dim i As String
i = WDAPP.Selection.Information(3)
WDAPP.Selection.TypeText(text:=p)
WDAPP.documents.add(TextBox2.Text)
WDAPP.Selection.MoveDown(Unit:=WDAPP.wdParagraph, Count:=1)
WDAPP.Selection.EndKey()
WDAPP.Selection.ParagraphFormat.TabStops.Add(Position:=WDAPP.CentimetersToPoints(15.24), Alignment:=WDAPP.wdAlignTabRight, Leader:=WDAPP.wdTabLeaderDashes)
WDAPP.Selection.TypeText(Text:=vbTab)
WDAPP.Selection.TypeText(Text:=i)
WDAPP.Selection.TypeText(Text:=vbCrLf)
End With
End If
兩個textbox分別是讀的文件地址,和寫的文件地址。
寫上去是沒錯的,執行的時候粗體的那行![圖片說明](http://img.ask.csdn.net/upload/201501/02/1420168623_867857.jpg)就是圖片的報錯
應該怎麼修改,還有我打開那個被寫的文件時候說是被綁定了不能操作,這是什麼情況
![圖片說明](http://img.ask.csdn.net/upload/201501/02/1420168660_496589.jpg)
http://msdn.microsoft.com/en-us/library/office/ff838730(v=office.15).aspx