Bookmark question

J

James T.

Access 2000

I have a small database that I have to issue a work order
for each record each week. I would like to output it to a
document that is a template for the work order. I can do
this for one record, but I would like to do it for all
records at one time with a separate work order for each
record. I have tried doing this in a report, but couldn't
get it to work. I am more comfortable doing it in a
document with bookmarks. Here is a sample of my code that
will print one record:

Private Sub Command10_Click()

' start Microsoft Word.
Set wordApp = CreateObject("Word.Application")

With wordApp

' Make the application visible.
.Visible = True
' Open the document.
.Documents.Open
("C:\DataLetters\NoticeToProceed.doc")
' Move to each bookmark and insert text from the
form.
.ActiveDocument.Bookmarks("To").Select
.Selection.Text = (CStr(Forms!Proceed!To))
.etc ....
End With

'''objWord.ActiveDocument.PrintPreview
wordApp.ActiveDocument.PrintOut Background:=False
wordApp.ActiveDocument.Close wdDoNotSaveChanges

wordApp.Quit wdDoNotSaveChanges
Set wordApp = Nothing

Exit Sub

MergeButton_Err:
' If a field on the form is empty
' remove the bookmark text and continue.
If Err.Number = 94 Then
wordApp.Selection.Text = ""
Resume Next
End If
End Sub

Is there anyway to do all records?

Any help greatly appreciated.

Thanks,

James
 
A

Albert D. Kallal

I am going to suggest that you dump those book marks and give my sample word
mega a try.

My sample word merge lets you:

* Send a sql statement to the merge routines (this is exactly what you
need).

* Allows you to word enable any form with ONE line of code (no more hard
coding of fields in your code..it just works!).

* Has built in support for one record....

Give my sample data file a try (it is ready to go)..and there are notes on
my site on HOW to use this example in YOUR application.

Try it out..here:

http://www.attcanada.net/~kallal.msn/msaccess/msaccess.html
 
J

James T.

-----Original Message-----
I am going to suggest that you dump those book marks and give my sample word
mega a try.

My sample word merge lets you:

* Send a sql statement to the merge routines (this is exactly what you
need).

* Allows you to word enable any form with ONE line of code (no more hard
coding of fields in your code..it just works!).

* Has built in support for one record....

Give my sample data file a try (it is ready to go)..and there are notes on
my site on HOW to use this example in YOUR application.

Try it out..here:

http://www.attcanada.net/~kallal.msn/msaccess/msaccess.htm l

--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn
Albert,

Thanks! I downloaded it and tried your example and it
seems to work fine. Now can you tell me how I use my
existing Word Doc as a template?

Thanks,

James
 
J

James T.

Albert,

I have it working per your instructions on your web
site, however my question to the group was to merge all
records and your instructions and app do not have this
ability, or I am missing something.

Can you tell me how to use your app to merge all records?

Thanks,

James
 
A

Albert D. Kallal

James T. said:
Albert,

I have it working per your instructions on your web
site, however my question to the group was to merge all
records and your instructions and app do not have this
ability, or I am missing something.

Can you tell me how to use your app to merge all records?

Yes, take a look at the sample merge form... ..you will notice a merge all
records buttion RIGHT beside the merge single word!

You can look at the code behind that butiton to see how this works. In fact,
BETTER is to build a query, and then have the merge code use that query.

For direct sql simply go:

dim strSql as string

strSql = "select * from tblCustomers Order by LastName"

MergeAllWord (strSql)

As mentioned...if you want..you can build the sql in the query builder..and
even place in the conditions you want. Then go:

MergeAllWord ("YouNiceQueryThatYourBuiltGoesHere")

I would suggest you use the query builder
Now can you tell me how I use my existing Word Doc as a template?

Just do what everyone does to copy text...simply cut and paste the text from
your old document into a new template that my code creates. (I think that is
the way most people copy text between docuemts. So, simply take your
document, hightlight the text, and then launch my template system. Paste in
your text. You of course have to go through your text and dump those
ugly/terrriable book marks..and then insert the fields from that NICE drop
down that my merge system gives you).

Good luck...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top