![]() |
Modifying built in document properties using an excel macro
I am having an interesting problem while trying to set the built in
document properties of a word file using an excel macro. I am picking the values from an excel sheet and trying to set the values for each ..doc file in a folder one by one. The following code runs perfect the first time and sets the new values for all built in properties for all the word files in the "C:\Test" folder. But when i run the code a second time with new values, it executes without any error but doesn't set the new values (the doc files have the old values itself). Can someone help please? Urgent.... Sub Macro2() Dim i As Integer Dim wordApp As Word.Application Dim wordDoc As Word.Document Set wordApp = CreateObject("Word.Application") With Application.FileSearch ..NewSearch ..LookIn = "C:\Test" ..SearchSubFolders = False ..Filename = "*.doc" ..Execute For i = 1 To .FoundFiles.count ThisFile1 = Range("B" & i + 1).Value ThisFile2 = Range("C" & i + 1).Value ThisFile3 = Range("D" & i + 1).Value Set wordDoc = wordApp.Documents.Open(Filename:=.FoundFiles(i)) wordApp.ActiveDocument.BuiltinDocumentProperties(" Title") = ThisFile2 wordApp.ActiveDocument.BuiltinDocumentProperties(" Subject") = ThisFile3 wordApp.ActiveDocument.BuiltinDocumentProperties(" Author") = ThisFile4 wordDoc.Save wordDoc.Close Next i End With End Sub |
Modifying built in document properties using an excel macro
This should tell you want you need:
http://www.cpearson.com/excel/docprop.htm There also DSOFile.dll, which comes in different versions: http://support.microsoft.com/kb/224351 various reports of good/bad results. NickHK "Rak****" wrote in message oups.com... I am having an interesting problem while trying to set the built in document properties of a word file using an excel macro. I am picking the values from an excel sheet and trying to set the values for each .doc file in a folder one by one. The following code runs perfect the first time and sets the new values for all built in properties for all the word files in the "C:\Test" folder. But when i run the code a second time with new values, it executes without any error but doesn't set the new values (the doc files have the old values itself). Can someone help please? Urgent.... Sub Macro2() Dim i As Integer Dim wordApp As Word.Application Dim wordDoc As Word.Document Set wordApp = CreateObject("Word.Application") With Application.FileSearch .NewSearch .LookIn = "C:\Test" .SearchSubFolders = False .Filename = "*.doc" .Execute For i = 1 To .FoundFiles.count ThisFile1 = Range("B" & i + 1).Value ThisFile2 = Range("C" & i + 1).Value ThisFile3 = Range("D" & i + 1).Value Set wordDoc = wordApp.Documents.Open(Filename:=.FoundFiles(i)) wordApp.ActiveDocument.BuiltinDocumentProperties(" Title") = ThisFile2 wordApp.ActiveDocument.BuiltinDocumentProperties(" Subject") = ThisFile3 wordApp.ActiveDocument.BuiltinDocumentProperties(" Author") = ThisFile4 wordDoc.Save wordDoc.Close Next i End With End Sub |
Modifying built in document properties using an excel macro
Thanks Nick,
Those links were a great help. I have got it running now. Help really appreciated. |
Modifying built in document properties using an excel macro
Hi Nick
Thanks so much for the help. I went to those links and thry really helped me in solving the problem. I have figured the way out. Thanks again. Regards, Rak**** |
All times are GMT +1. The time now is 05:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com