Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-19-2025, 03:13 PM
DruB DruB is offline Mailmerge document Stapling Windows 11 Mailmerge document Stapling Office 2021
Novice
Mailmerge document Stapling
 
Join Date: Feb 2025
Posts: 3
DruB is on a distinguished road
Default Mailmerge document Stapling

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
Reply With Quote
  #2  
Old 02-19-2025, 03:28 PM
macropod's Avatar
macropod macropod is offline Mailmerge document Stapling Windows 10 Mailmerge document Stapling Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 02-19-2025, 04:55 PM
DruB DruB is offline Mailmerge document Stapling Windows 11 Mailmerge document Stapling Office 2021
Novice
Mailmerge document Stapling
 
Join Date: Feb 2025
Posts: 3
DruB is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 02-20-2025, 02:12 AM
macropod's Avatar
macropod macropod is offline Mailmerge document Stapling Windows 10 Mailmerge document Stapling Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #5  
Old 02-20-2025, 04:01 PM
DruB DruB is offline Mailmerge document Stapling Windows 11 Mailmerge document Stapling Office 2021
Novice
Mailmerge document Stapling
 
Join Date: Feb 2025
Posts: 3
DruB is on a distinguished road
Default

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!
Reply With Quote
  #6  
Old 02-20-2025, 04:59 PM
macropod's Avatar
macropod macropod is offline Mailmerge document Stapling Windows 10 Mailmerge document Stapling Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Glad you got it sorted.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mailmerge document Stapling Macro to insert an image to a word mailmerge document based on the value of a mailmerge field? Jake93 Mail Merge 3 07-02-2019 05:38 PM
Mailmerge document Stapling Suppress blank lines in mailmerge of excel reports into word document beefcake2000 Mail Merge 1 11-10-2017 12:54 PM
Mailmerge document Stapling Template From MailMerge Document 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
Mailmerge document Stapling Split MailMerge document agujoa Mail Merge 3 04-08-2012 11:26 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:41 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft