Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

VB Database/Ado/MsWord Help

Options
  • 28-03-2003 5:33pm
    #1
    Registered Users Posts: 446 ✭✭


    I'm trying to make a letter in vb that shows up some fields that the user has entered in at the vb prompt.


    E.g Vb form asks for name and address... I want to then click on a button that will show a letter that has that persons name and address in...and be able to change it for each user...much like Mail Merge...any ideas?

    Thanks

    Kegan:confused:


Comments

  • Registered Users Posts: 437 ✭✭Spunj


    Are you actually trying to do a MSWord mail merge?
    What does clicking a button/showing a form have to do with ADO?
    You need to provide more information about what you are trying to achieve.

    If it is Word, there are MSWord programming objects available if you have Office installed on the machine - have a look in the references in VB. The programming help inside word should give you examples of merging (all the code in Word is done in VB scripting).


  • Registered Users Posts: 446 ✭✭kegan5


    Vb form has has an ado control linked to database...
    there are Text boxes asking for name and address...

    the textboxes are bound to adocontrol ....

    SO now what I want is to be able to click on a button and have a preset letter that will now have the name and address from the person that just entered details...

    It should work like Mail Merge...but I'm not sure if thats possible with this?


  • Closed Accounts Posts: 8,264 ✭✭✭RicardoSmith


    Yes you need to give more information or at least clarify what you are trying to do. At the moment what you are asking could be done in either VB/Word/Access depending on the exact requirements.


  • Registered Users Posts: 446 ✭✭kegan5


    you need more info???


  • Registered Users Posts: 437 ✭✭Spunj


    Forget for a second that you are updating a database at all.
    You need a word object in which you need to replace 2 fields for one record?

    On this form you need a reference to Microsoft Word Object and some properties for the name and address you want to merge to.
    You have a document perpared with bookmark placeholders named name and address or whatever.
    Now all you have to figure out is how you:
    Create the word object
    Open a document
    Merge 2 fields
    Save/print the document
    Clean up .

    Im not sure if you need to even see the document on screen? If so you can do this on another form.

    Im trying to help you without actually doing this for you, you have to put some effort into researching what you need to do yourself.

    You are posing questions without giving any indication that you have even tried to solve them :/


  • Advertisement
  • Closed Accounts Posts: 8,264 ✭✭✭RicardoSmith


    For example... (and I'm not trying to be smart in case it looks that way)..
    Originally posted by kegan5
    I'm trying to make a letter in vb that shows up some fields that the user has entered in at the vb prompt.egan:confused:

    A letter could be just a text field. Or it could be a word doc. Which do you want. Whats a vb prompt? Do you mean a VB form? or a Word form?
    E.g Vb form asks for name and address... I want to then click on a button that will show a letter that has that persons name and address in

    Does this letter already exist? If so where, if not do you want to create it?
    ...and be able to change it for each user...much like Mail Merge...any ideas?

    What is it? The letter, the name the address, what?

    I suspect (and I'm only guessing) you want to create a text entry form in word that allows the user to enter a name and address. for these details to be searched for (where?) and a list of docs/letters displayed that contain the name (and/or) address entered. The user should then be able to edit the doc/letter etc. Then you want to be able to do this for any number of names addresses? All this can be done in word better then VB IMO.

    ....or I could be completely off track...:)


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Create the word object
    Open a document
    Merge 2 fields

    One good way to learn how to do this in vb is to record a macro in Word doing them, then look at the code behind the macro. This is how I learned most of my Office stuff.

    A note on cleaning up, make sure you quit the word application then set the instance of it to nothing, i.e:
    
    objWordApp.Quit [COLOR=green]'// Insert save options here[/COLOR] 
    [COLOR=blue]Set[/COLOR] objWordApp = [COLOR=blue]Nothing[/COLOR]
    
    

    This will prevent memory leaks, Word with VB is a nuisance for memory leaks.


  • Closed Accounts Posts: 8,264 ✭✭✭RicardoSmith


    VBA in word is pretty powerful on it own, and not to hard to pick up either. Recording and the then examining macros is good place to start though to use it properly you'd need some basic knowledge of programming. I found VBcity.com especially the forums a great help.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Yeah, I reckon Kegan5 has enough knowledge to handle it.


  • Registered Users Posts: 446 ✭✭kegan5


    Thanks!!!
    I think i get yas...not sure...i'll try to give it a go


  • Advertisement
Advertisement