Graham
Sat Feb 18 01:52:23 CST 2006
You are welcome
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site
http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Steve C wrote:
> Graham,
>
> Your code is extremely helpful. Thank you so much.
>
> "Graham Mayor" wrote:
>
>> Modify the styles in the normal template (or some other preferred
>> template) then apply that template to the files with the update
>> styles option set. Manual formatting in the documents may cause some
>> headaches.
>>
>> Sub ApplyNormalTemplate() 'to all files in a folder
>> Dim myFile As String
>> Dim PathToUse As String
>> Dim myDoc As Document
>> Dim NormalPath
>> 'set option to create backups
>> Options.CreateBackup = True
>> 'set the location of Normal.dot
>> NormalPath = Chr(34) & _
>> Options.DefaultFilePath(wdUserTemplatesPath) & _
>> "\Normal.dot" & Chr(34)
>> With Dialogs(wdDialogCopyFile)
>> If .Display <> 0 Then
>> PathToUse = .Directory
>> Else
>> MsgBox "Cancelled by User"
>> Exit Sub
>> End If
>> End With
>> If Documents.Count > 0 Then
>> Documents.Close SaveChanges:=wdPromptToSaveChanges
>> End If
>> If Left(PathToUse, 1) = Chr(34) Then
>> PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
>> End If
>> myFile = Dir$(PathToUse & "*.doc")
>> While myFile <> ""
>> Set myDoc = Documents.Open(PathToUse & myFile)
>> With ActiveDocument
>> .UpdateStylesOnOpen = True
>> .AttachedTemplate = NormalPath
>> End With
>> myDoc.Close SaveChanges:=wdSaveChanges
>> myFile = Dir$()
>> Wend
>> End Sub
>>
>>
>> --
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>> Graham Mayor - Word MVP
>>
>> My web site www.gmayor.com
>> Word MVP web site
http://word.mvps.org
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>
>> Steve C wrote:
>>> The problem is that I'm dealing with hundreds of existing documents
>>> that need to be changed, and doing them individually isn't an option
>>> from a time standpoint.
>>>
>>> "Edward Thrashcort" wrote:
>>>
>>>> Wouldn't it be easier simply to use Format Style Modify?
>>>>
>>>> Eddie
>>>>
>>>>> *From:* "Steve C <SteveC@discussions.microsoft.com>
>>>>> *Date:* Thu, 16 Feb 2006 19:35:03 -0800
>>>>>
>>>>> I need to build a procedure that searches an active document for
>>>>> the existence of a series of customized styles and replaces
>>>>> existing settings with updated settings. For example, if styles
>>>>> named SCT and/or ACT exist in the document, find all instances
>>>>> where they're applied and replace the indents, tabs, paragraph
>>>>> formatting, etc. with updated ones (keeping the same style
>>>>> names). Any suggestions would be appreciated!