a single mailmerged document with listing multi schedules in it (1 Viewer)

NT100

Registered User.
Local time
Tomorrow, 01:11
Joined
Jul 29, 2017
Messages
148
Hi,

I've a mail merge work with MS ACCESS table with the following fields and values

Teacher_Name Schedule
Jeff Putman 2nd June, 2018
Jeff Putman 12th June, 2018
Jeff Putman 22nd June, 2018
Jeff Putman 30th June, 2018
Carl Trump 1st July, 2018
Carl Trump 11st July, 2018
Carl Trump 18th July, 2018
Carl Trump 26th July, 2018

How do I make a single mailmerged document to "Jeff Putman", for example, and 4 details of the schedules in that single letter?

Best.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:11
Joined
May 7, 2009
Messages
19,169
Try first the Report.
If you stll want word; usebookmark, its simpler to program.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:11
Joined
Feb 19, 2002
Messages
42,971
It will be much easier to create a report with a subreport and export as a .pdf file if what you are trying to get to is a file you can send to someone. But we really need to know what requirement you are actually trying to fulfill because there are always multiple options.

As for Word. I don't use mail merge because my requirements are almost always too complex and include subsets of data such as you have. Therefore I use OLE automation and use VBA to populate the bookmarks. If you want to use tabular subsets, you would build the "table" by concatennating columns and rows. The columns are separated by tabs and at the end of each row, you need a CrLf. Then you put the string into a bookmark and while the bookmark is still selected, apply the table format you want. I can post an example if you need it. I have a couple of applications that handle thousands of documents and those are controlled by tables that map data fields to bookmarks in documents so a user can add a new document and create the mapping all by himself. No programming is required. In the example, I use the curmudgeon method and everything is hard-coded. You would not want to use this method if you have more than a couple of documents to create.
 

NT100

Registered User.
Local time
Tomorrow, 01:11
Joined
Jul 29, 2017
Messages
148
I welcome your example for working out to combine multiple rows of data to one recipient.

Thank you again.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:11
Joined
Feb 19, 2002
Messages
42,971
The sample documents are in a separate zip file to keep file size down.
 

Attachments

  • SampleLetters.zip
    446.9 KB · Views: 47
  • SampleWordAutomation180206accdbNoDocs.zip
    413.3 KB · Views: 59

NT100

Registered User.
Local time
Tomorrow, 01:11
Joined
Jul 29, 2017
Messages
148
I tried to set MS ACCESS to word 2016 reference to "..Open any code module and go to Tools/References and set a Word reference to your installed version..". I can't do that as there's no such reference can be selected. Pls. see the attached file for details.


I downloaded them. They are the same database. However, I can't preview them with the error of "5174-Sorry, we couldn't find your file. Was it move, renamed, or deleted?".

Would you further advice on this?
 

Attachments

  • word reference.docx
    89.9 KB · Views: 45

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:11
Joined
Feb 19, 2002
Messages
42,971
As the instructions state, you need to set a reference to Word to make the code work. In my case, I am using O2016 so my reference looks like this:

Choose the Word library that you have installed. The code should work with all libraries since it doesn't rely on any new features.
 

Attachments

  • WordReference.JPG
    WordReference.JPG
    94.1 KB · Views: 187

NT100

Registered User.
Local time
Tomorrow, 01:11
Joined
Jul 29, 2017
Messages
148
I still can't locate Microsoft Word 16.0 Object Library with my MS Office 2016. There's no such an entry in it.

I read an article "A reference to "Microsoft Word 16.0 Object Library" could not be added" at https://social.msdn.microsoft.com/F...ect-library-could-not-be-added?forum=netfxbcl. with the link, it said that "the office 2016, you will add reference from Reference Manager> COM> Type libraries directly.".

I ran the sample application, it started an empty word.

BTW, I am aware of the C:\Data\UsefulDatabases. I tried to put the two word documents from your Sample application there. I still got the same error msg of "5174".

Regards.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:11
Joined
Feb 19, 2002
Messages
42,971
YOU DO NOT NEED WORD 2016!! The instructions - again:

s the instructions state, you need to set a reference to Word to make the code work. In my case, I am using O2016 so my reference looks like this:
...
Choose the Word library that you have installed. The code should work with all libraries since it doesn't rely on any new features.

Do you have ANY version of Word installed? If you are using O365, are you using a version that actually installs the Office suite on your hard drive or are you running cloud versions. You MUST have Word installed locally to automate it. You CANNOT be using a cloud version.
 

NT100

Registered User.
Local time
Tomorrow, 01:11
Joined
Jul 29, 2017
Messages
148
YOU DO NOT NEED WORD 2016!! The instructions - again:



Do you have ANY version of Word installed? If you are using O365, are you using a version that actually installs the Office suite on your hard drive or are you running cloud versions. You MUST have Word installed locally to automate it. You CANNOT be using a cloud version.

My MS installed Office is the Office Suite. Pls. see the attached file.

Thank you.
 

Attachments

  • MSInf.JPG
    MSInf.JPG
    35.2 KB · Views: 36

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:11
Joined
Feb 19, 2002
Messages
42,971
You need to open ANY code module and go to Tools/References. The existing references are checked. You need to scroll down the list until you find MS word and check it.
 

NT100

Registered User.
Local time
Tomorrow, 01:11
Joined
Jul 29, 2017
Messages
148
You need to open ANY code module and go to Tools/References. The existing references are checked. You need to scroll down the list until you find MS word and check it.

There's no Microsoft Word 16.0 Object Library in the Reference list. Pls. view the attached screenshots.

Can I download it from net?
 

Attachments

  • MSWord_reference_1.jpg
    MSWord_reference_1.jpg
    100 KB · Views: 32
  • MSWord_reference_2.jpg
    MSWord_reference_2.jpg
    98.5 KB · Views: 39

isladogs

MVP / VIP
Local time
Today, 17:11
Joined
Jan 14, 2017
Messages
18,186
There's no Microsoft Word 16.0 Object Library in the Reference list. Pls. view the attached screenshots.

Can I download it from net?

Have a look at screenshot 2. It's there and ticked!!!!!!! :)
 

Users who are viewing this thread

Top Bottom