Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-13-2021, 03:46 PM
Alex1s85 Alex1s85 is offline Delete blank table rows in merged document and split document in docx and pdf based on excel rows Windows 10 Delete blank table rows in merged document and split document in docx and pdf based on excel rows Office 2016
Advanced Beginner
Delete blank table rows in merged document and split document in docx and pdf based on excel rows
 
Join Date: Oct 2019
Location: Thessaloniki, Greece
Posts: 30
Alex1s85 is on a distinguished road
Default Delete blank table rows in merged document and split document in docx and pdf based on excel rows

Hello to everyone,




I was wondering if there a way to set this issue.


Cheers
Reply With Quote
  #2  
Old 05-13-2021, 04:41 PM
Guessed's Avatar
Guessed Guessed is offline Delete blank table rows in merged document and split document in docx and pdf based on excel rows Windows 10 Delete blank table rows in merged document and split document in docx and pdf based on excel rows Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You need to attach a sample document to demonstrate what your issue is. If it is a mail merge document then also post a sample data source.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 05-13-2021, 05:16 PM
macropod's Avatar
macropod macropod is offline Delete blank table rows in merged document and split document in docx and pdf based on excel rows Windows 10 Delete blank table rows in merged document and split document in docx and pdf based on excel rows Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

See, for example: https://www.msofficeforums.com/150021-post2.html

As for splitting the document, see See Split Merged Output to Separate Documents in the Mailmerge Tips and Tricks page:
https://www.msofficeforums.com/mail-...ps-tricks.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 05-22-2021, 02:15 AM
Alex1s85 Alex1s85 is offline Delete blank table rows in merged document and split document in docx and pdf based on excel rows Windows 10 Delete blank table rows in merged document and split document in docx and pdf based on excel rows Office 2016
Advanced Beginner
Delete blank table rows in merged document and split document in docx and pdf based on excel rows
 
Join Date: Oct 2019
Location: Thessaloniki, Greece
Posts: 30
Alex1s85 is on a distinguished road
Default

Hello again,

I need some help here, please.

I've attached a sample letter and the pool from excel.

I have to delete empty table rows - after mail merge - and split the letters into word and pdf. The pages per letter may vary and I want to have the headers and the footers after the split.

I use the following code to split the letters into word and pdf but I haven't found a way to combine this code with the "Sub DeleteEmptyRows ()"

Code:
Option Explicit

Const FOLDER_SAVED As String = "destination folder" 'Makes sure your folder path ends with a backward slash
Const SOURCE_FILE_PATH As String = "your pool's full path"

Sub TestRun()
Dim MainDoc As Document, TargetDoc As Document
Dim dbPath As String
Dim recordNumber As Long, totalRecord As Long

Set MainDoc = ActiveDocument
With MainDoc.MailMerge
    
        ' if you want to specify your data, insert a WHERE clause in the SQL statement
        .OpenDataSource Name=SOURCE_FILE_PATH, sqlstatement=SELECT  FROM [Sheet1$]
            
        totalRecord = .DataSource.RecordCount

        For recordNumber = 1 To totalRecord
        
            With .DataSource
                .ActiveRecord = recordNumber
                .FirstRecord = recordNumber
                .LastRecord = recordNumber
            End With
            
            .Destination = wdSendToNewDocument
            .Execute False
            
            Set TargetDoc = ActiveDocument

            TargetDoc.SaveAs2 FOLDER_SAVED & .DataSource.DataFields(CID).Value & .docx, wdFormatDocumentDefault
            TargetDoc.ExportAsFixedFormat FOLDER_SAVED & .DataSource.DataFields(CID).Value & .pdf, exportformat=wdExportFormatPDF
            
            TargetDoc.Close False
            
            Set TargetDoc = Nothing
                    
        Next recordNumber

End With

Set MainDoc = Nothing
End Sub


Any help would be just valuable
Attached Files
File Type: xlsx sample.xlsx (13.6 KB, 13 views)
File Type: docx Test letter.docx (23.7 KB, 7 views)
Reply With Quote
  #5  
Old 05-22-2021, 03:05 AM
macropod's Avatar
macropod macropod is offline Delete blank table rows in merged document and split document in docx and pdf based on excel rows Windows 10 Delete blank table rows in merged document and split document in docx and pdf based on excel rows Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

All you would need to do is change:

Sub DeleteEmptyRows()
in the link to:
Sub DeleteEmptyRows(TargetDoc As Document)
and, in the same sub, change:
ActiveDocument.Tables
to:
TargetDoc.Tables

You can delete both 'Application.ScreenUpdating' rows from the 'DeleteEmptyRows' sub, too.

Then, after the line:
Set TargetDoc = ActiveDocument
in your existing sub, insert:
Call DeleteEmptyRows(TargetDoc)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 05-22-2021, 12:05 PM
Alex1s85 Alex1s85 is offline Delete blank table rows in merged document and split document in docx and pdf based on excel rows Windows 10 Delete blank table rows in merged document and split document in docx and pdf based on excel rows Office 2016
Advanced Beginner
Delete blank table rows in merged document and split document in docx and pdf based on excel rows
 
Join Date: Oct 2019
Location: Thessaloniki, Greece
Posts: 30
Alex1s85 is on a distinguished road
Default

That works perfectly.

Thank you very much Macropod!!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete blank table rows in merged document and split document in docx and pdf based on excel rows Split table cell into multiple rows based on a delimiter WJSwanepoel Word Tables 4 02-02-2021 10:33 PM
Delete blank table rows in merged document and split document in docx and pdf based on excel rows split table rows based Dynamic values generated for row Naveen Dhanaraj Word Tables 10 03-06-2020 03:23 AM
Delete blank table rows in merged document and split document in docx and pdf based on excel rows Mail Merge - split merged documents and rename each split document based on text in header FuriousD Word VBA 1 05-12-2019 04:06 AM
Delete blank table rows in merged document and split document in docx and pdf based on excel rows Design Macro or Code to Delete Table Rows When Null/Blank/Empty Upon Doc Close/Save aaghd72 Word VBA 8 02-18-2019 11:22 AM
Delete blank table rows in merged document and split document in docx and pdf based on excel rows Delete blank rows between the two rows that contain data beginner Excel Programming 5 12-26-2014 12:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:08 PM.


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