Reply
 
Thread Tools Display Modes
  #1   Report Post  
David Gladstone
 
Posts: n/a
Default macro to enter data and print doc

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.
--
In the hope that asking the question is often the beginning of greater
understanding
  #2   Report Post  
Graham Mayor
 
Posts: n/a
Default

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.

--

Graham Mayor - Word MVP

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




David Gladstone wrote:
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.



  #3   Report Post  
David Gladstone
 
Posts: n/a
Default

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

"Graham Mayor" wrote:

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.

--

Graham Mayor - Word MVP

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




David Gladstone wrote:
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.




  #4   Report Post  
Graham Mayor
 
Posts: n/a
Default

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.

--

Graham Mayor - Word MVP

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





David Gladstone wrote:
Graham - many thanks for your elegant response. The REF field works
well but I am having problems 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

"Graham Mayor" wrote:

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.

--

Graham Mayor - Word MVP

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




David Gladstone wrote:
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.




  #5   Report Post  
David Gladstone
 
Posts: n/a
Default

Thanks

"Graham Mayor" wrote:

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.

--

Graham Mayor - Word MVP

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





David Gladstone wrote:
Graham - many thanks for your elegant response. The REF field works
well but I am having problems 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

"Graham Mayor" wrote:

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.

--

Graham Mayor - Word MVP

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




David Gladstone wrote:
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.





Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I print a mail merge data source without the main document Lynn A Mailmerge 0 January 21st 05 10:39 AM
How to print blank merge data as a blank line? YYS Mailmerge 1 January 17th 05 12:18 PM
How do I update Word 2002 to create merged faxes? Imperfect26 Mailmerge 1 January 16th 05 08:10 AM
Merge Error - Contains Too Few Data Field jdb Mailmerge 1 January 14th 05 04:17 PM
How to print addresses on envelopes from Outlook Contacts data ? JimBo Row Mailmerge 1 December 20th 04 08:04 AM


All times are GMT +1. The time now is 10:40 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"