LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to print the document properties in Excel? pcastillo Setting up and Configuration of Excel 1 February 28th 09 06:25 PM
Modifying Built-in Menus RoyPVan Excel Discussion (Misc queries) 0 October 19th 07 05:37 PM
Displaying Document Properties in Excel AlwaysFroosh! Excel Worksheet Functions 3 September 26th 06 07:30 PM
Modifying a database based on changes in an Excel document shai-hulud Excel Programming 1 July 4th 06 07:02 AM
Excel document properties insert into a cell Mark Excel Discussion (Misc queries) 3 December 16th 04 02:05 PM


All times are GMT +1. The time now is 05:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"