Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-19-2022, 02:09 AM
pilucs pilucs is offline Vba word macro erase rows from tables Windows 10 Vba word macro erase rows from tables Office 2010
Novice
Vba word macro erase rows from tables
 
Join Date: Nov 2022
Posts: 2
pilucs is on a distinguished road
Arrow Vba word macro erase rows from tables

Hello everyone,
I need some help.
I premise that I am very ignorant about VBA & Macros and I apologize infinitely.
I wanted to ask if there is a VBA macro to solve my two problems.

1) I have 63 word files, all with the same layout. In each of them, there are two tables, in each table, rows 2,3 and 4 are not needed by me and should be deleted.


Is there a macro to do this instead of opening the files one by one and deleting the above rows manually?

2) I have a word file where there is a paragraph that I need to insert in each file. The paragraph was created with mail merge and contains different data for each word file where it needs to be copied.
Is there a VBA macro such that by reading the unique name of the word file (in my case it is a code), can copy the text produced by mail merge into each individual file?

Thank you all for the help and please do not hesitate to write to me if something is not clear.
Dario.
Reply With Quote
  #2  
Old 11-19-2022, 02:57 PM
Guessed's Avatar
Guessed Guessed is offline Vba word macro erase rows from tables Windows 10 Vba word macro erase rows from tables Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
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

In both cases, the tasks CAN be written for you but they don't already exist to do exactly what you are asking.

The first question has enough information to be created - assuming that the files are all contained in a folder and you can tell us how the code would determine where the folder is.

The second question can't be started without seeing the source information and target document because we can't see how the macro can:
1. Find the paragraph to copy
2. Align it with a specific document in an unknown location
3. Work out where the target location to paste is in that specific document.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 11-21-2022, 06:05 AM
pilucs pilucs is offline Vba word macro erase rows from tables Windows 10 Vba word macro erase rows from tables Office 2010
Novice
Vba word macro erase rows from tables
 
Join Date: Nov 2022
Posts: 2
pilucs is on a distinguished road
Default

Andrew,

thanks for your reply.
How may I create a VBA macro for 1st point? do you have any starting code where to work on maybe?


In which way I can provide info for 2nd point?
Thanks.
Reply With Quote
  #4  
Old 11-21-2022, 06:26 AM
gmayor's Avatar
gmayor gmayor is offline Vba word macro erase rows from tables Windows 10 Vba word macro erase rows from tables Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The first part can easily be achieved using Document Batch Processes with the following custom process. The second part would require more information about what to look for and what to replace it with.

Code:
Function FixTable(oDoc As Document) As Boolean
Dim oTbl As Table
Dim i As Long
    On Error GoTo Err_Handler
    For Each oTbl In oDoc.Tables
        For i = oTbl.Rows.Count To 1 Step -1
           Select Case i
            Case 2, 3, 4
                oTbl.Rows(i).Delete
            Case Else
           End Select
        Next i
    Next oTbl
    FixTable = True
lbl_Exit:
    Exit Function
Err_Handler:
    FixTable = False
    Resume lbl_Exit
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Tags
macro, mail merge, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro type check columns of multiple tables - return mismatch rows zizz Excel Programming 3 08-28-2021 09:26 PM
How do I on MS Word VBA add and remove rows in the tables using command button macros? ananas1171 Word VBA 6 06-30-2021 07:51 AM
VBA color of visible gridlines of tables word (with some merged cells in first rows) Alvaro.passi Word VBA 0 07-18-2017 09:11 AM
Vba word macro erase rows from tables Word 10 Tables: Column to auto number 1.1, 1.2 etc in sequential rows FrauBaker12 Word Tables 7 06-24-2016 11:52 PM
Vba word macro erase rows from tables Macro to delete all empty rows from all tables braddgood Word VBA 15 10-02-2015 01:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:47 AM.


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