vb & word

Posted on 1999-11-09
Medium Priority
Last Modified: 2010-05-02
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 ?

Question by:terencebeh
  • 3
  • 2

Expert Comment

ID: 2194032
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

Author Comment

ID: 2194082
I need to use Word document as it is the template (with some graphics intact).
LVL 71

Accepted Solution

Éric Moreau earned 200 total points
ID: 2194513
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.EndKey Unit:=wdStory
            .Selection.InsertBreak Type:=wdPageBreak
        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.
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.


Author Comment

ID: 2195870
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 ?

LVL 71

Expert Comment

by:Éric Moreau
ID: 2196797
You already open one document in word? Open a second document and call the CopyToLastPage method.

Author Comment

ID: 2197018
the above worked just fine for me. Thanks.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question