Results 1 to 5 of 5

Thread: struggling to feed data into MSWORD thru VB.NET

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    61

    struggling to feed data into MSWORD thru VB.NET

    I created Bookmarks in my word template pima.doc.I am trying to insert data into Bookmarks in word document by fetching data from MS Access thru VB.NET.

    But when i try to write properties for word application ,it gives error.

    same code work in VB6;
    ie
    objword.application.activedocument.bookmarks("today").range.insertafter Rs.Fields(1).Value.(this works fine in VB6)

    But i could not write same line in VB.NET
    what i have to do solve the problem.



    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:\ram\Address\pima\pima.doc", False)
    objword.Visible = True
    objword.Activate()

    Please help me out.

    thanks

  2. #2
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question

    I haven't tried to do something like this (yet) but perhaps you could take a VB6 example and convert it into VB.NET.

    That would give you code that worked. And an idea of what you're doing wrong.

    Just a suggestion.
    ~Peter


  3. #3
    Addicted Member
    Join Date
    Oct 2002
    Posts
    210

    Thumbs down


  4. #4
    Addicted Member
    Join Date
    Oct 2002
    Posts
    210

    Thumbs down


  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    61
    Okay.I will convert from VB to VB.NET.

    Thanks for suggesions.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width