Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-07-2017, 09:54 AM
MisrIdley MisrIdley is offline Extract Document Property and insert it into the same document, for many files in a folder Windows 10 Extract Document Property and insert it into the same document, for many files in a folder Office 2013
Novice
Extract Document Property and insert it into the same document, for many files in a folder
 
Join Date: Dec 2017
Posts: 1
MisrIdley is on a distinguished road
Unhappy Extract Document Property and insert it into the same document, for many files in a folder


I would like to extract a Document Property "Title" and insert it into the same document, just at the beginning. There is most likely text at that location, it can go before or after just as long as it is inserted once, for many files in one folder. I found code by macropod about opening a document, running macro, then closing and saving document, all located in one folder. I figured inserting the Title like a quick part code would work but doesn't seem to, I don't want to go in all 300 files and add bookmarks, and all files already have the document property 'Title' filled out.
Huge n00b here


Code:
Sub UpdateDocuments()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
  Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
     With wdDoc

    'Call your other macro or insert its code here- NO IDEA HERE.... 

    Selection.HomeKey = wdStory
     ActiveDocument.Range.InsertAfter "DocPROPERTY  Title"
    
    ' 


   .Close SaveChanges:=True
  End With
  strFile = Dir()
Wend
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
  #2  
Old 12-07-2017, 12:41 PM
macropod's Avatar
macropod macropod is offline Extract Document Property and insert it into the same document, for many files in a folder Windows 7 64bit Extract Document Property and insert it into the same document, for many files in a folder Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

That's as simple as:
Code:
  With wdDoc
    .Range.InsertBefore .BuiltInDocumentProperties("Title") & vbCr
    .Close SaveChanges:=True
  End With
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
document, extract, property

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
From a docx report document save all images in a cell from the document to a folder censura Word VBA 1 05-13-2017 12:54 AM
Vba code to save document as pdf using document property text and rename folder. staicumihai Word VBA 1 12-21-2015 07:39 AM
Document Property Question ksigcajun Word VBA 9 10-14-2014 11:26 AM
Extract Document Property and insert it into the same document, for many files in a folder Insert image based on document custom property anandyrh Word 1 08-14-2013 12:08 AM
Remove title property from all files in a folder konopca Word VBA 2 12-04-2012 10:54 AM

Other Forums: Access Forums

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