Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-26-2023, 07:56 PM
knpaddac knpaddac is offline Merging word documents containing tables Windows 10 Merging word documents containing tables Office 2016
Novice
Merging word documents containing tables
 
Join Date: Jan 2018
Posts: 13
knpaddac is on a distinguished road
Default Merging word documents containing tables

I frequently have to merge many (even hundreds of them) Word documents into one. Recently many of these have included content that is in tables within the documents. In the resulting doc, I am getting line breaks (enters) between the content from each cell but I want it to be tabs. Can anybody help me with this? I have included the code below as I am currently using it:




Code:
Sub Import_Text()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document, rtfFile As Document
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.rtf", vbNormal)
Set wdDoc = ActiveDocument
While strFile <> ""
  Set rtfFile = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False, ConfirmConversions:=False)
  wdDoc.Range.InsertAfter rtfFile & vbCr & rtfFile.Range.Text & vbCr
  rtfFile.Close SaveChanges:=True
  strFile = Dir()
Wend
Set rtfFile = Nothing: Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging word documents containing tables Merging Word documents kp4bnx Word VBA 4 03-10-2021 02:49 PM
Merging word documents containing tables Batch merging of Word documents Harry Gateaux Word VBA 6 11-19-2020 09:58 AM
Merging word documents containing tables Updating links while merging Word documents ndw Word VBA 1 11-10-2017 01:07 PM
Merging word documents containing tables Merging two tables in WORD with VBA ffinley Word VBA 3 03-14-2017 07:43 PM
Merging different documents in one big document keeping the chapters, figure numbers and tables village Word 8 06-06-2016 04:16 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:18 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