|
-
Dec 19th, 2002, 01:30 AM
#1
Thread Starter
Member
MSword with VB.NET
Hi,
I would like to read the data from Ms Word .I feed the data through VB.NET and store the value in MS Access.I want to read the data from Ms Word.
But it works well in VB6.Samething i try to do it in VB.NEt
but error is comming when writing
objword.application.activedocument.bookmarks("date").
(i would like to write code like:Because i wrote in VB6 and work well there.
objWord.Application.ActiveDocument.Bookmarks("Name").Range.InsertAfter Rs.Fields(1).Value)
samething i tried in VB.NET but it didnot allow me to write
it gives error
objword.application.activedocument.bookmarks("date").
error is :interface'word.bookmarks'cannot be indexed because it has no default property.
Pl help me out.
thanks.
the code is
Dim firstdate As Date
Dim sAppPath As String
Dim conn As ADODB.Connection
conn = New ADODB.Connection()
Dim objword As Word.Application
sAppPath = IO.Path.Combine(Application.StartupPath, "Addressdb.mdb")
conn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data source=" & sAppPath & ";Mode=Share deny None"
conn.Open()
End Sub
Private Sub ButSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButSubmit.Click
Dim Conn As ADODB.Connection
Dim oRs As ADODB.Recordset
oRs = New ADODB.Recordset()
oRs.Open("pcaddress", Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
oRs.AddNew()
oRs.Fields("Name").Value = TxtName
oRs.Fields("LastName").Value = TxtLast
oRs.Fields("Address").Value = TxtAddress
oRs.Fields("city").Value = TxtCity
oRs.Fields("State").Value = CmbState
oRs.Fields("country").Value = TxtCountry
oRs.Fields("date").Value = LblDate
oRs.Update()
oRs.Close()
Conn.Close()
End Sub
Private Sub ButReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButReport.Click
Dim Rs As ADODB.Recordset
Rs = New ADODB.Recordset()
Dim conn As ADODB.Connection
conn = New ADODB.Connection()
Dim objword As Word.Application
objword = New Word.Application()
Dim sSQL As String
sSQL = "SELECT * FROM pcAddress where Regid=1;"
Rs.Open("sSQL", conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic)
If Rs.BOF = True And Rs.EOF = True Then
MessageBox.Show("No Records Returned", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
objword.Application.Documents.Add("C:\program files\microsoft visual studio\VB98\VBAWord\Project1\address.doc", False, )
objword.Visible = True
objword.Activate()
objword.Application.ActiveDocument.Bookmarks("date").
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|