Results 1 to 10 of 10

Thread: Connecting To Word

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    Greenville
    Posts
    73
    Hey does anyone please have any code or advice on how to start or connect to Word and pull a document up off the hard drive so it will then paste info from a db into fields in the Word Document. Thankyou I will be so happy.

  2. #2
    Guest
    Dude,

    No problem log into http://www.planetsourcecode.com and do a search on word. A hundred and one examples of exactly what you want. This are downloadable etc

    Regards.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    Greenville
    Posts
    73
    I just looked around for a while in there and did not find anything. I feel hopeless, does anyone have any other help or direction for me. I have been using the following code and it opens my document fine but now I cannot find how in the world to paste info into the particular textboxes that I have put on the Word document. Please help. Whats next?

    '-- Show Microsoft Word
    objWord.Visible = True

    '-- Add new Document
    objWord.Documents.Open ("c:\payoff quote.ltr.doc")

    '-- Add text to Document
    objWord. -------- STuck

  4. #4
    Lively Member
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    84

    Arrow

    Have you already had a look at these articles?

    Creating Reports with Microsoft Word
    http://www.vb-world.net/activex/wordreports/

    Beginning Word Programming In VB
    http://www.vbsquare.com/beginning/begword/

    Hope this helps!

  5. #5
    Member
    Join Date
    Mar 2000
    Posts
    62
    OK, this code is awesome. i have been using it for awhile. i dont use text boxes in my Word documents. I simply just type a variable name anywhere on the document. This code finds the variable name in the document and then replaces it with whatever you pass it.

    'Name of report file, change path to whatever is applicable

    Set WrdDoc = WrdApp.Documents.Open("c:\ErrNotification.doc")

    ' Calling subroutines with header and data

    Call RepPara("ErrDate", DateStamp)
    Call RepPara("ErrNum", ErrNumBox)
    Call RepPara("ErrDescription", ErrDescription

    WrdDoc.PrintOut

    'Close the original form document
    WrdDoc.Saved = False
    WrdDoc.Close False

    Public Sub RepPara(Header As String, Data As String)
    With WrdApp.Selection.Find
    .ClearFormatting
    .Text = Header
    .Execute Forward:=True
    End With
    Clipboard.Clear
    If Data = "" Then Data = " "
    Clipboard.SetText (Data)
    WrdApp.Selection.Paste
    Clipboard.Clear
    End Sub

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    Greenville
    Posts
    73
    Thanks for the input but I still cannot get it to work it just will not paste into my document. The document is a form with text made in word and I need it to paste in the first textboxes. I really canot fit what you sent JJK I wish I could. And I have browsed the other sources sent by nins and jethro and have not found anything that makes it work. Maybe if I could just look at someones simple code on it. I am so frustrated.

  7. #7
    Member
    Join Date
    Mar 2000
    Posts
    62
    i have another mail merge sample i can send you. this is a little more complicated. it uses data from a database to fill merge fields on a Word Document.

    I am kind of confused to what you are trying to do. You are creating a Word Document and everything through VB? you can do that but, why couldnt you create a Word Document through Word, put on the variables where you want the data to be placed, then call that Word document and put in the data through the code i sent you earlier.


  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    Greenville
    Posts
    73
    Yeah what I have I am using is a document created in Word (as a form) that has textboxes that can only be filled with info on the whole document. All I need to do is fill in the first one and then tab thru the the rest as I fill in each one in order. I would like to use what you have sent before but I am using textboxes and I do not really follow how to use your code with them. If you would like I would like to e-mail a copy of my word document but I need to get your e-mail. Double Thanks.

  9. #9
    Member
    Join Date
    Mar 2000
    Posts
    62

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    Greenville
    Posts
    73
    Its there!

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