creating enelopes with MSword

hi

i have  msaccess database with list of addresses.. i want to create and print the envelopes for selected addresses from vb application .. how can i do that ? do i need to use msword for creating envelopes first and then print...?
is there  any other way.?. i wud like to  pass the dimensions of envelopes in run time if possible ..any help wud be gr8ly appreciated .. thank u
108aAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
You have several options

1. Use the Access report system
2. Use the Printer object
3. Use MSWord mailmerge

The real benefits of Access report and Word mailmerge are best gained by non-programmers from within the applications. Programatically it's easier to user the Printer Object.


This shows one  way to use it

Sub PrintRoutine(rs as RecordSet)
Dim prn As Printer
Dim i As Integer
Dim j As Integer
For Each prn In Printers
If prn.DeviceName = ("MyPrinter") Then
        Exit For
    End If
Next prn

Set Printer = prn
'Printer.PaperSize = vbPRPSEnv9 'not all printers will accept any or all possible values
'Printer.PaperBin = vbPRBNEnvManual 'not all printers will accept any or all possible values
Printer.Orientation = vbPRORLandscape
Printer.Height = 1440 * 4.5 'inches to twips
Printer.Width = 1440 * 9.25
rs.MoveFirst
Do Until rs.EOF
    For i = 1 To 6
        Printer.Print vbTab & vbTab & vbTab & rs.Fields(i) & vbCrLf
    Next i
    Printer.NewPage
rs.MoveNext
Loop
Printer.EndDoc
Close rs
End Sub


Incidentally, you have 9 questions open (including this one)
0
108aAuthor Commented:
thanks  GrahamSkan..  iwill  try to close all the questions asap..

is  this code is for printing   Envelopes? im able to print on the plane paper ..but i  wud like to know how to print on  10X4 Inch. envelop.. thank u
0
GrahamSkanRetiredCommented:
A lot depends on the printer and printer driver.

What happens now when you put envelopes in the printer?
 
Can you print these envelopes using another application, e.g. Word?

0
108aAuthor Commented:
hi GrahamSkan.. sorry for delay in reply...i couldn't  check your comments as i was on vacation..  im  able to print on A4 paper  ..its printing on left hand side top corner   , its not printing on envelope... im able to print it from msword .. looks like to be prob with x,y coordinates...
 thank you
0
GrahamSkanRetiredCommented:
Yes,

You'll have to position the text by using more tabs (or spaces), or by setting CurrentX & CurrentY before printing each line.

I don't know what sort of printer you have, or how you feed in envelopes. Some have a particular bin for envelopes, others would use an adjustable bin & for others you might have to use a manual feed.

If you do have a special bin, you'll have to experiment to find out what number to call it by. The help for the printer object gives a list of constants (like vbPRBNEnvManual).

If you have an adjustable bin, you may have to set up the PaperSize, or the Height & Width properties, but you probably don't have to. It will only be necessary if the printer goes into standby displaying a message asking for the stipulated paper to be loaded.

I have just tried to an simple Inkjet printer which does not have a special bin, but does have an adjustable width. It will print on whatever paper size is loaded, even if the program asks for a different size.

So the main problem is to position the text in the right position.

This snippet positions the address more towards the centre of the envelope.

Dim prn As Printer
Dim i As Integer
Dim j As Integer
Dim LeadingSpace As String
For Each prn In Printers
If prn.DeviceName = ("EPSON Stylus COLOR 800") Then
        Exit For
    End If
Next prn
LeadingSpace = String(100, " ")
Set Printer = prn
Printer.Orientation = vbPRORLandscape ' if envelopes are end-feed
Printer.PaperSize = vbPRPSEnv10 'ignored by printer
For j = 1 To 2
    'move down 10 lines
    For i = 1 To 10
        Printer.Print ""
    Next i
   
    Printer.Print LeadingSpace & "Addressee " & j
    For i = 1 To 6
        Printer.Print LeadingSpace & "Address Line " & i
    Next i
    Printer.NewPage

Next j
Printer.EndDoc

*** Tip ***

Most of the methods for printing to the printer object and to a form are the same, so you may want use a form for testing layout, especially if you have to pay for the ink/toner and paper yourself.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.