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 (Many Thanks...)Next Topic (print cd covers) New Topic New Poll Post Reply
AndreaVB Forum : Printing : How to Print in Word using VB
Poster Message
ary
Level: Guest


icon How to Print in Word using VB  Archived to Disk

dear all,

hi...., I need help  
I have problem in printing using Ms-Word.
For example : I already create a template document file, and to printing using that template i have to passing parameter from VB to Ms-Word, and the paramater value taken from database.
and the parameter i send depend on user choice.
so is it possible to do ?

thanks for your attention...

regards
ary

17-07-2002 at 04:58 AM
| Quote Reply
SteveG
Level: Sage


Registered: 15-04-2002
Posts: 56
icon Re: How to Print in Word using VB  Archived to Disk

You can use a word template and fill it from VB, I have written an application which fills over 160 fields in a word template.

I will try to point you in the write direction. Code follows.

Dim WordDoc As New Word.Application

'   Open Word with your template
WordDoc.Documents.Add ( "YourTemplate.dot" )

With WordDoc.ActiveDocument
   .FormFields(YourField1).Result = "AString"
   .FormFields(YourField2).Result = AVariable
    
    etc

   .FormFields.Locked = True
   .PrintOut
End With

WordDoc.Quit
    

This uses form fields on the template which you have to name when creating the template. If the FormFields.Locked property is not set to true they can be overwritten with blanks on printing.

I gleaned most of the commands from the VBA help files on Word97 and a lot of trial and error testing.

If I can be of more assistance let me know.

Good luck.

31-07-2002 at 08:55 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Printing : How to Print in Word using VB
Previous Topic (Many Thanks...)Next Topic (print cd covers) 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