Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-22-2020, 11:44 PM
venkat_m venkat_m is offline Extract Document ID and description from header in multiple Word documents and paste in new word doc Windows 10 Extract Document ID and description from header in multiple Word documents and paste in new word doc Office 2016
Novice
Extract Document ID and description from header in multiple Word documents and paste in new word doc
 
Join Date: May 2020
Posts: 2
venkat_m is on a distinguished road
Exclamation Extract Document ID and description from header in multiple Word documents and paste in new word doc

Problem Statement: Require VBA Code - Need to Extract Document ID and description from header in multiple MS Word documents and should be automatically populated in a separate word document which has columns document type, Document ID, location of evidence, revision and description.



Multiple MS Word documents Folder location:

C:\Users\MURALV05\Desktop\Value Creation\Value Creation\1. SUPPLIER EVALUATION & AGREEMENTS

C:\Users\MURALV05\Desktop\Value Creation\Value Creation\2. PLANNING

C:\Users\MURALV05\Desktop\Value Creation\Value Creation\3. DESIGN INPUT

C:\Users\MURALV05\Desktop\Value Creation\Value Creation\4. DESIGN OUTPUT

C:\Users\MURALV05\Desktop\Value Creation\Value Creation\5. DESIGN VERIFICATION

C:\Users\MURALV05\Desktop\Value Creation\Value Creation\8. RISK MANAGEMENT

C:\Users\MURALV05\Desktop\Value Creation\Value Creation\10. DESIGN CHANGE HISTORY LOG
Attached Images
File Type: jpg pic 2.jpg (51.2 KB, 6 views)

Last edited by venkat_m; 05-22-2020 at 11:48 PM. Reason: add new info
Reply With Quote
  #2  
Old 05-23-2020, 03:28 AM
macropod's Avatar
macropod macropod is online now Extract Document ID and description from header in multiple Word documents and paste in new word doc Windows 7 64bit Extract Document ID and description from header in multiple Word documents and paste in new word doc Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,358
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Cross-posted at: VBA Code to extract Document ID and Description from header in multiple MS Word documents and automatic populated in a separate word document - Stack Overflow
For cross-posting etiquette, please read: Excelguru Help Site - A message to forum cross posters
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 05-23-2020, 03:57 AM
venkat_m venkat_m is offline Extract Document ID and description from header in multiple Word documents and paste in new word doc Windows 10 Extract Document ID and description from header in multiple Word documents and paste in new word doc Office 2016
Novice
Extract Document ID and description from header in multiple Word documents and paste in new word doc
 
Join Date: May 2020
Posts: 2
venkat_m is on a distinguished road
Default VBA Code needs correction as per my problem statement

Code:
Sub ExtractTablesFromMultiDocs()
  Dim objTable As Table
  Dim objDoc As Document, objNewDoc As Document
  Dim objRange As Range
  Dim strFile As String, strFolder As String
 
  '  Initialization
  strFolder = InputBox("C:\Users\MURALV05\Desktop\Value Creation\Value Creation: ")
  strFile = Dir(strFolder & "" & "*.docx", vbNormal)
 
  Set objNewDoc = Documents.Add
 
  '  Process each file in the folder.
  While strFile <> ""
    Set objDoc = Documents.Open(FileName:=strFolder & "" & strFile)
    Set objDoc = ActiveDocument
 
    For Each objTable In objDoc.Tables
      objTable.Range.Select
      Selection.Copy
 
      Set objRange = objNewDoc.Range
      objRange.Collapse Direction:=wdCollapseEnd
      objRange.PasteSpecial DataType:=wdPasteRTF
      objRange.Collapse Direction:=wdCollapseEnd
      objRange.Text = vbCr
    Next objTable
 
    objDoc.Save
    objDoc.Close
    strFile = Dir()
  Wend
 
End Sub

Last edited by macropod; 05-23-2020 at 03:59 AM. Reason: Added code tags
Reply With Quote
Reply

Tags
macros in word, ms word 16, vba code

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to extract bookmarked data from Word document and insert into another Word Document VStebler Word VBA 3 05-03-2018 05:02 PM
Need to extract e-mail addresses from lots of word documents zebedee398 Word VBA 0 12-01-2017 03:29 AM
Switch between multiple Word documents within the same Word document kai Word VBA 2 11-20-2017 10:13 PM
batch extract all tables in multiple word documents ZaidaBa Word Tables 3 05-08-2017 10:22 PM
Extract Data from Word Documents hiwire03 Word VBA 3 01-29-2016 09:19 PM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 02:01 AM.


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