![]() |
#1
|
|||
|
|||
![]()
I have been trying the code from https://www.msofficeforums.com/mail-...documents.html in my MailMerge and, when I would run it, the computer would do nothing. I asked ChatGPT why that might be. I gave me some new code to add, including a record counter and a message box that would activate if my mail merge found no records in my source document. Sure enough, when I ran that code I got the "no records" message. But when I run the mail merge manually, everything works fine with no issues. When I record a simple macro to print one record everything works fine with no issues. My data source is a table in another word document, it is not an excel file or anything else.
What could be going on? Last edited by macropod; 02-20-2025 at 05:01 PM. Reason: Solit from original thread |
#2
|
||||
|
||||
![]()
ChatGPT often produces garbage code, which is why many organizations, forums, etc. ban its use.
Do you get the mailmerge SQL prompt when you open your mailmerge main document?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Yes, I do get the SQL prompt. I have tried to run the mail merge code with both the data source file open and closed.
|
#4
|
||||
|
||||
![]()
Are you sure your mailmerge main document is the active one when you run the macro?
What happens if you insert: Msgbox "Records: " & .MailMerge.DataSource.RecordCount after: With ActiveDocument
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
Macropod, sorry I just saw this response. I tried something different today. I copied my source data from a table in Word doc to an Excel spreadsheet and macro worked perfectly!
|
#6
|
||||
|
||||
![]()
Glad you got it sorted.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Jake93 | Mail Merge | 3 | 07-02-2019 05:38 PM |
![]() |
beefcake2000 | Mail Merge | 1 | 11-10-2017 12:54 PM |
![]() |
LouGibson | Mail Merge | 1 | 06-13-2016 03:14 PM |
how to copy addresses in word document to excel/mailmerge list | msnarayanan | Mail Merge | 4 | 10-17-2015 03:17 PM |
![]() |
agujoa | Mail Merge | 3 | 04-08-2012 11:26 PM |