Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / January 2005

Tip: Looking for answers? Try searching our database.

macro to enter data and print doc

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Gladstone - 28 Jan 2005 11:35 GMT
I need some help to write a "simple" macro that will allow me to enter data
from the keyboard and place it in a document tjen to save the documenet and
print it.
The overall task is paper based and not suitable (due to lack of funds) to
working directly from a laptop.  It involves entering a clients name and
address in the appropriate places in a form of six pages, then saving the
name and address to a file (or appending to a text file) then printing the
pages with thename and address entered.

I have some very elementry knowledge of vba and I am sure that it is easy
using a message box and beginner's vba but I do not know where to start.
Signature

In the hope that asking the question is often the beginning of greater
understanding

Graham Mayor - 28 Jan 2005 14:41 GMT
If the only changes you are making to the document are to the name and
address, then pop up the forms menu and insert a form field for the name and
another for the address at their first locations in the document and check
the calculate on exit check boxes of both fields' properties. At the other
locations use REF fields to recall the information you have just entered.
Lock the form and save it as a template.

No vba required.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> I need some help to write a "simple" macro that will allow me to
> enter data from the keyboard and place it in a document tjen to save
[quoted text clipped - 8 lines]
> easy using a message box and beginner's vba but I do not know where
> to start.
David Gladstone - 29 Jan 2005 15:45 GMT
Graham - many thanks for your elegant response.  The REF field works well but
I am having porblems getting the "form field" to work although this might be
due to my personal lack of understanding.
The solution does not generate or update a text file, eg csv that would
provide a database or simple list of contacts.  Maybe I did notstress the
importance of this feature.
My own rather fuzzy thoughts involved a MSGBOX, FILLIN or ASK as a front end
from where the namefield, addressfield would appear a) in all pages of the
form letter (there are  6 pages and the namefield appears 20 times) then
prints all pages  and b) updates or appends a csv file database.
Sorry I did not make this clear

> If the only changes you are making to the document are to the name and
> address, then pop up the forms menu and insert a form field for the name and
[quoted text clipped - 17 lines]
> > easy using a message box and beginner's vba but I do not know where
> > to start.
Graham Mayor - 30 Jan 2005 08:02 GMT
The general principle of bookmarks and ref fields will still work, but the
requirement to append the input to a data file converts this from a simple
task to a more complicated one. Essentially you would run a macro on exit
from the last form field used, to gather the data from the bookmarks and
then write it to another document. If you start with a blank document called
(say) names.doc and you have two fields called Text1 and Text2 then
something along the lines of

Dim sName, sAddress, sOutput As String
sName = ActiveDocument.Bookmarks("Text1").Range
sAddress = ActiveDocument.Bookmarks("Text2").Range
sOutput = sName & ", " & sAddress & vbCr
Documents.Open FileName:="Names.doc"
Selection.EndKey Unit:=wdStory
Selection.InsertAfter sOutput

would add your field content to the names.doc file. It needs work to produce
a useable function, but it should set you on your way - there are plenty
of vba enthusiasts active in the Word vba groups if you need further help
with this.

A more elegant alternative would be to create a userform to gather the data,
but the principle is the same. There is lots of information on userforms on
the MVP web site (link in sig. block) to get you started with this.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Graham - many thanks for your elegant response.  The REF field works
> well but I am having problems getting the "form field" to work
[quoted text clipped - 39 lines]
>>> easy using a message box and beginner's vba but I do not know where
>>> to start.
David Gladstone - 30 Jan 2005 10:41 GMT
Thanks

> The general principle of bookmarks and ref fields will still work, but the
> requirement to append the input to a data file converts this from a simple
[quoted text clipped - 64 lines]
> >>> easy using a message box and beginner's vba but I do not know where
> >>> to start.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.