Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

Word macro: loop through tables
 
This Word macro code example edits all the table elements in a Word document.
Here, always the inner areas be transferred a table as formatted content to another table.
Shown: Word tables, selection, and range

 
Tutorial:
< iframe width = "854" height = "480" src = "https://www.youtube.com/embed/IqKiMQL1iwQ" frameborder = "0" allowfullscreen > < / iframe >
 
 
The complete Word macro code in vba (visual basic for applications):

Sub Makro1()
 
'< init >
Dim doc As Document
Set doc = ActiveDocument
'</ init >

Dim intCount As Integer
intCount = doc.tables.Count
'half 4->2
Dim intHalf As Integer
intHalf = intCount / 2
 
'--< Table >--
Dim iTable As Integer
For iTable = 1 To intHalf
'----< inLoop: table >----
'-< source >-
Dim source_Table_Range As range
Set source_Table_Range = doc.tables(intHalf + iTable).range
source_Table_Range.Select
Selection.Copy
'-</ source >-
 
'-< target >-
Dim target_Table_Range As range
Set target_Table_Range = doc.tables(iTable).range
target_Table_Range.Select
Selection.Delete
Selection.PasteAndFormat wdFormatOriginalFormatting
'-</ target >-
'----</ inLoop: table >----
Next
End Sub
 

 
 
Mobile

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de