borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Printing a receipt from list)Next Topic (vb printing) New Topic New Poll Post Reply
AndreaVB Forum : Printing : Creating small Word doc files in VB
Poster Message
kronous
Level: Guest


icon Creating small Word doc files in VB

Hi,

I have an app that (as part of it) uses VB's Tabbed dialog control. The form has four tabs that tabs to its own page with text input boxes on each page for inputting information.

As it is, I use a print utility (using a Print button) that prints a hard copy of all the inputted data but now, I would like a utility that will take the the same data and create an MS Word document (.Doc) file.

Is that possible?

If you need more information, let me know and I will help out!

Any help is MUCH appreciated!

Thanks

14-10-2003 at 05:22 AM
| Quote Reply
Shady
Level: VB Guru


Registered: 08-07-2002
Posts: 305
icon Re: Creating small Word doc files in VB

Hi There,

It is possible to automate Word using VB, you can use bookmarks in word to help you format your document.

How much information do you want to transfer to word?

Can you use a template i.e. is some of the information always the same?

Let me know and I should be able to give you some code snippets to help you out!



Shady

____________________________
I don't wanna die... but I ain't keen on livin' either

14-10-2003 at 08:16 AM
View Profile Send Email to User Show All Posts | Quote Reply
kronous
Level: Guest

icon Re: Creating small Word doc files in VB

Hello,

Thanks for replying to my question!

I think if I give you my website address so that you can see exactly what I'm trying to accomplish, it'll make things much easier.

I'm not open for business yet, just trying to get it to a reliable point- so far, so good!

If you'd like,
my site address is: http://www.realtynetworkinggroup.com

Then you can scroll down to my: "How it Works" link and click on that. It will take you to a page that has a screen shot of a "Seller's Property Profile" form. It shows my 4 tabbed tab control. As you can see, each tab page has a description in front of a check box.

This form is in my free software package I offer which works in conjunction with my site. Everything is explained on my site.

My print utility prints out each description with an "X" in front of it, or not- depending on whether the property owner has that attribute or not.

It's designed to print out all four tabbed pages of info on one sheet of paper.

But since I'd like all property info from the tabbed dialog box (including their images) sent via e-mail, I would like all of the text info sent by Word.doc

All of this is so I can make up their ad and post in on my website.

I hope all this helps and if you want, I can copy and past my entire print routine I modified (extensively) from a utility I found on the web.

You may have need for it too sometime, modified for your own use!

Also, if you're interested, if my business takes off and you are well-versed in VB, my software is going to need a make-over mostly in ad display storage. I'm always looking for a partner or two on a contractual basis.

Thanks

16-10-2003 at 04:26 PM
| Quote Reply
Shady
Level: VB Guru


Registered: 08-07-2002
Posts: 305
icon Re: Creating small Word doc files in VB

OK,

I Think the next stage here is for me to knock together a small program which take some user data and makes a Word Document for you.

It will not take me very long as I have a couple of routines already written, I just need to modify them slightly.

Send me and email (shadyshotton@hotmail.com) and I will send you a .zip file and some instructions for a simple .DOC creation project, then we can go from there.OK

Regards

Shady

____________________________
I don't wanna die... but I ain't keen on livin' either

17-10-2003 at 08:57 AM
View Profile Send Email to User Show All Posts | Quote Reply
appiekap
Level: Guest

icon Re: Creating small Word doc files in VB

hello, i'm programming a program wich must print a standaard lay-out page with information from an external database. i only need the code so the data from a textbox will be inserted in the standaard word lay-out file on the good positions and then be printed

05-03-2004 at 12:53 PM
| Quote Reply
Shady
Level: VB Guru


Registered: 08-07-2002
Posts: 305
icon Re: Creating small Word doc files in VB

Hi there,

I think this little code snippet should be enough to get you started.  The way it works is very simple, you place bookmarks in your document where you want the information inserted.  Then you use the Word Object library to send information to these bookmarks.

Make sure you have selected the Word Library in VB, you will find it under Project > References.

Let me know if you have any problems.



Dim oWord As Word.Application
    Dim oDoc As Word.Document

    'Start Word and open the document template.
    Set oWord = CreateObject("Word.Application")
    oWord.Visible = True

    Set oDoc = oWord.Documents.Open(FileName:="C:\MyDoc.doc", _
    ReadOnly:=True)
    
oDoc.Bookmarks("Text").Range.Text = TextBox

oDoc.PrintOut
oDoc.Close (Word.WdSaveOptions.wdDoNotSaveChanges)

oWord.Quit


Regards

Shady

____________________________
I don't wanna die... but I ain't keen on livin' either

08-03-2004 at 09:22 AM
View Profile Send Email to User Show All Posts | Quote Reply
r.wiggins
Level: Guest

icon Re: Creating small Word doc files in VB

Shady - wonder if you can help me please.  It's along the same lines as the details you've already explained to the two other people.

I'd like to send data from a VB text box to a specific merge field on an already created Word Template.

In a bit more detail:

The text box data, is from an XML file (which I've already completed) I have a Word template which already contains merge fields (can't edit these, I have to use the current fields) and I'd like the data from the text box to go to the specific merge field on the Word template??

e.g.  Text box called: txtPolicyNumber to write to Word document merge field called: «POLARIS.Policy_PolicyNo»

If you could help here I'd really appreciate it.  Also, if you need any further info please let me know, e.g. Name of one of the merge fields.

Thanks

Ross

15-03-2004 at 09:24 PM
| Quote Reply
Shady
Level: VB Guru


Registered: 08-07-2002
Posts: 305
icon Re: Creating small Word doc files in VB

Hi there,

I'm not sure what you mean by a specific merge field, and regardless of its properties, the above post details the only way I know to be able to transfer information from VB to Word.

If you can insert a Bookmark into your merge field, then you can use the code I have posted above, if not the only way for me to see what it is you require, if for you to email me your template, then I can play about with it and maybe come up with a solution.

You can send it to phil_shotton@hotmail.com.

Regards

Shady

____________________________
I don't wanna die... but I ain't keen on livin' either

16-03-2004 at 01:10 PM
View Profile Send Email to User Show All Posts | Quote Reply
appiekap
Level: Guest

icon Re: Creating small Word doc files in VB

thnx shady,

it worked a lot, but i've got one little problem.
if i work with word XP Englisch, the program works fine, but when i use Word 2000 Dutch, the program gives an error while running word.

17-03-2004 at 02:01 PM
| Quote Reply
appiekap
Level: Guest

icon Re: Creating small Word doc files in VB

thnx shady,

it worked a lot, but i've got one little problem.
if i work with word XP Englisch, the program works fine, but when i use Word 2000 Dutch, the program gives an error while running word.

17-03-2004 at 02:01 PM
| Quote Reply
vimala169
Level: Guest

icon Re: Creating small Word doc files in VB

quote:
kronous wrote:
Hi,

I have an app that (as part of it) uses VB's Tabbed dialog control. The form has four tabs that tabs to its own page with text input boxes on each page for inputting information.

As it is, I use a print utility (using a Print button) that prints a hard copy of all the inputted data but now, I would like a utility that will take the the same data and create an MS Word document (.Doc) file.

Is that possible?

If you need more information, let me know and I will help out!

Any help is MUCH appreciated!

Thanks


11-05-2004 at 06:08 AM
| Quote Reply
Shady
Level: VB Guru


Registered: 08-07-2002
Posts: 305
icon Re: Creating small Word doc files in VB

quote:
it worked a lot, but i've got one little problem.
if i work with word XP Englisch, the program works fine, but when i use Word 2000 Dutch, the program gives an error while running word.


This is to do with the object library that you use to control word, each different version has a different version of the library, for instance Word XP uses Word Library 11, and WOrd 2000 uses Word Library 10.

If you create your app using the earlier Word library it will work with both 2000 and XP, but if you use the latest library it will only work with XP.

If you want to use a different version of the Word library, first you need to find out what file is used by selecting PROJECT > REFERENCES and then select the word library.

You should find it uses the file MSWORD.OLB, if you have a version of this file from a previous version of word you should click browse and point VB to that version of the library!

Shady

____________________________
I don't wanna die... but I ain't keen on livin' either
11-05-2004 at 08:11 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Printing : Creating small Word doc files in VB
Previous Topic (Printing a receipt from list)Next Topic (vb printing) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder