vb & word

1. I had written a program which is supposed to print out a letter (word document) for each row in the dbgrid. What I did is that I execute fileprint of the word object for each row. The funny thing is that I didn't get all my rows in the dbgrid printed. Sometimes, it skips a few rows. I try to see the pattern unfortunately no specific pattern found. Probably this is due to the spooling not able to response fast enough. Does anyone here have a solution to this problem ?

2. I thought of a way to resolve the above problem. If there is a way to append this word document into 1 document and program to execute the fileprint once. But, how do I append the word document ?

LVL 1
terencebehAsked:
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.

PennywisdomCommented:
If you absolutly want to create a word document I can'T help you

But if you just want to print the letter then you can use the printer.print method
0
terencebehAuthor Commented:
I need to use Word document as it is the template (with some graphics intact).
0
Éric MoreauSenior .Net ConsultantCommented:
You can use this proc to copy the current document at the end of the preceding document:

Public Sub CopyToLastPage()
    With mwaWordApp
        If .Documents.Count > 1 Then
            .Selection.WholeStory
            .Selection.Copy
            CloseDoc
            .Selection.EndKey Unit:=wdStory
            .Selection.InsertBreak Type:=wdPageBreak
            .Selection.Paste
        End If
    End With
End Sub

You should open the new document in new document, replace the text you have to replace and then copy the document at the end of the preceding.
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
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

terencebehAuthor Commented:
how do you exactly open a new document in the new document ?

Would you be able to provide me with a complete set of codes ?

Thanks.
0
Éric MoreauSenior .Net ConsultantCommented:
You already open one document in word? Open a second document and call the CopyToLastPage method.
0
terencebehAuthor Commented:
the above worked just fine for me. Thanks.
0
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.