08-10-19, 02:17 AM
Imports word = Microsoft.Office.Interop.Word
Public Class Form12
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim strpathopen As String = ""
Dim ofd As New OpenFileDialog
With ofd
.Filter = "word Document(*.docx)|*.docx|word 97-2003 Document(*.doc)|*.doc|Template(*.dotx)|*.dotx "
.FilterIndex = 3
.Title = "chose word file"
.FileName = "chose only word file"
.ShowDialog()
End With
If ofd.FileName <> "" Then
TextBox1.Text = ofd.FileName
strpathopen = ofd.FileName
End If
End Sub
Public Sub Txtbox_to_template(templatepath As String)
Try
Dim oword As Word.Application
Dim oDoc As New word.Document
oword = CreateObject("word.Application")
oDoc.Bookmarks("age1").Range.Text = Form10.TextBox3.Text
oDoc.Bookmarks("abod1").Range.Text = Form10.TextBox4.Text
oDoc.Bookmarks("hip1").Range.Text = Form10.TextBox5.Text
oDoc.Bookmarks("abcd").Range.Text = Form10.TextBox7.Text
oword.Visible = True
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim templatepath As String = ""
Txtbox_to_template(TextBox1.Text)
End Sub
End Class
ما الخطاء بلكود عند التشغيل ا=تضهر لي رساله عضو المجموعه المطلوب غير موجود
Public Class Form12
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim strpathopen As String = ""
Dim ofd As New OpenFileDialog
With ofd
.Filter = "word Document(*.docx)|*.docx|word 97-2003 Document(*.doc)|*.doc|Template(*.dotx)|*.dotx "
.FilterIndex = 3
.Title = "chose word file"
.FileName = "chose only word file"
.ShowDialog()
End With
If ofd.FileName <> "" Then
TextBox1.Text = ofd.FileName
strpathopen = ofd.FileName
End If
End Sub
Public Sub Txtbox_to_template(templatepath As String)
Try
Dim oword As Word.Application
Dim oDoc As New word.Document
oword = CreateObject("word.Application")
oDoc.Bookmarks("age1").Range.Text = Form10.TextBox3.Text
oDoc.Bookmarks("abod1").Range.Text = Form10.TextBox4.Text
oDoc.Bookmarks("hip1").Range.Text = Form10.TextBox5.Text
oDoc.Bookmarks("abcd").Range.Text = Form10.TextBox7.Text
oword.Visible = True
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim templatepath As String = ""
Txtbox_to_template(TextBox1.Text)
End Sub
End Class
ما الخطاء بلكود عند التشغيل ا=تضهر لي رساله عضو المجموعه المطلوب غير موجود
