• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:


I`ve got a fax form that needs to be automatically filled in
i want 6 textboxes that put the filled in info on certain locations on the faxform the faxform is a word document
how do i specify the locations in the form where the info
has to be filled in
5 textboxes are to get info about sender company city faxnumber and address the 6th one has to put the desired text for what`s needed on the fax on to the form
please reply to this question
  • 3
  • 2
1 Solution

I'm afraid I don't have the answer for you but rest assured, someone will, and usually it will appear pretty soon. You don't need to give us an extra prod by asking us to please reply and by putting the question IN CAPITALS. There are quite a few very good VB experts here and they are all eager to help. The 180 points you put up are also very generous so that will help ;-)
Set a reference to Microsoft Word 8.0 Object Library

Use VBA to transfer the values.  

Set up Bookmarks in a Word 97 template doc. (.dot)  Example:

Bookmark in the position you want the "Company" variable to place.  Name the Bookmark mrkCompanyName.  Also have text in the bookmark as mrkCompanyName.

Next, open a Word object in VB.  

Dim sTemplateName
sTemplate = MyTemplateDoc.dot

  Set objWord = CreateObject("word.application")
  objWord.Documents.Open CurDir() &  sTemplateName

The next thing you want to do is set the variables for the text fields:

getCompanyName = frmMain.txtCompany.text
getFax = frmMain.txtFax.text

etc., etc.

Next, you're going to do a Find/Replace using the Bookmark you made in the Word template.


With objWord.Selection.Find
    .Text = "mrkCompany"
    .Replacement.Text = getCompanyName
    .Execute Replace:=wdReplaceAll, Forward:=True,        Wrap:=wdFindContinue
  End With

Repeat this for all the text fields you wish to pass.

Figure out how to handle the nulls using simple If statements like when to pass a second address line and when not to.

Next you have to print and close the document.

    objWord.ActiveDocument.Close savechanges:=wdDoNotSaveChanges

Next, Quit and set to Nothing

objWord.Application.Quit savechanges:=wdDoNotSaveChanges
    Set objWord = Nothing

You do not want to save the changes.  This way you can keep the template clean for future prints.

Before the close you may want to set a MsgBox to let the user know it's spooling to the printer.

That's about it.  Let me know if you need help with it.

Good Luck


One change to what I posted earlier.  In the replace/Find section, change mrkCompany to mrkCompanyName or whatever you named the bookmark to match.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

GOPPIEAuthor Commented:
Thank you very much
I`ll try to make this work
if i have some more questions can i mail them to you???
that is because i don`t have any more points to award you
is it that i can only get points by solving other people problems or can i upgrade my points in some menu?
this i ask because i`m very new to this type of help
my email address is erik_goppel@yahoo.com
please reply this message with your email address so we can exchange some info
i know some about c++ and visual c++ and study electronics
so maybe i can help you with that
well i`m going to try your info now
i`ll be waitng for your reply
thank you

GOPPIEAuthor Commented:
i`ve still got a question
i still keep getting this error message "object required"
i have tried evereything possible but i just gut stuck
could you please help me some more i`ll send the fax file to you including the template
if you`d please give me your email adress so i can get on with my work
You either didn't open the object in runtime properly, or you forgot to set the Reference for Microsoft Word 97 Object Library.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now