Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Lounger
    Join Date
    Jan 2001
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Find and replace with multiple files (office 2000)

    I have a directory full of documents that contain my company's address block. Our address has changed. Is there any way I can change the block without actually going in to each file individually? I figure once the file is open, I can use a macro to change the block quickly - but I don't want to have to open 800 files individually! I would love to know if anyone has an idea for a way to do a batch find/replace.

    Thanks for any help you can provide.

    Mary

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find and replace with multiple files (office 2000)

    Hi Mary:
    Someone may be able to write a macro that would open each file in a folder in turn, run a specific Find/Replace, save & close the document. (I don't know how.) However, I wanted to mention that, in the future, you are much better off having a source document that stores the information & use INCLUDETEXT fields in templates to create the documents with the information in fields. Then, when you need to update the information, you simply update the source file, & every other file is automatically updated. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  3. #3
    5 Star Lounger
    Join Date
    Oct 2002
    Location
    Wellington, Wellington, New Zealand
    Posts
    621
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find and replace with multiple files (office 2000)

    If it is in a single directory the following routine will probably do it.
    It is happy to open and operate on all files in a single directory that you currently have an open file in.

    In the following macro - change 'One' & 'Two' in the text and replacement.text lines.

    Option Compare Text
    Option Explicit

    Sub BulkFiles()
    ' This is a generic routine to obtain a set of files and then change each document
    ' as required by routine logic. It produces a hyperlink list of completed documents
    ' Designed so that simplistic tests can select
    ' Documents with particular attributes
    '
    Dim FS As Variant
    Dim FO As Variant
    Dim FL As Variant

    Dim ListString As String
    Dim ListStringURL As String
    Dim I As Long
    Dim IMax As Long
    Dim MyTemp As String
    Dim MyDoc As String
    Dim MyPath As String
    Dim DocMustBeOpened As Boolean
    Dim DocSavePreference As Variant
    Dim DocWanted As Boolean

    MyPath = Application.Options.DefaultFilePath(wdDocumentsPat h)
    If Documents.Count > 1 Then
    If ActiveDocument.Path <> "" Then
    MyPath = ActiveDocument.Path
    End If
    End If

    ChangeFileOpenDirectory MyPath

    Set FS = CreateObject("Scripting.FileSystemObject")
    Set FO = FS.getfolder(MyPath)

    Documents.Add
    MyDoc = ActiveDocument.Name
    DocMustBeOpened = True
    DocSavePreference = wdSaveChanges 'wdDoNotSaveChanges, wdSaveChanges, wdPromptToSaveChanges
    For Each FL In FO.Files
    MyTemp = FL.Name
    If Right(MyTemp, 4) = ".doc" Then
    DocWanted = True
    If DocMustBeOpened Then
    Documents.Open FileName:=MyTemp, ReadOnly:=DocSavePreference = wdDoNotSaveChanges, _
    AddToRecentFiles:=False
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = "One"
    .Replacement.Text = "Two"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    DocWanted = Selection.Find.Execute(Replace:=wdReplaceAll)
    If DocWanted Then
    ActiveDocument.Close savechanges:=DocSavePreference
    Else
    ActiveDocument.Close savechanges:=wdDoNotSaveChanges
    End If
    End If
    Else
    DocWanted = False
    End If
    If DocWanted Then
    Documents(MyDoc).Hyperlinks.Add Anchor:=Selection.Range, Address:= _
    MyPath & "" & MyTemp, SubAddress:=""
    Documents(MyDoc).Paragraphs.Add
    Selection.MoveDown Unit:=wdParagraph
    End If
    Next
    Set FS = Nothing
    Set FO = Nothing
    End Sub

  4. #4
    Lounger
    Join Date
    Jan 2001
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find and replace with multiple files (office 2000)

    Thanks to both of you! Appreciate the assistance.

  5. #5
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Find and replace with multiple files (office 2000)

    Hi Phil:

    Would the INCLUDETEXT also work with inserting a graphic and autotext for a template? What I have is 20+ offices that receive templates and upon doing File/New, they are prompted for some information, one of them being their office address which when they click the office, it automatically inserts their address.

    I have been told that with all of the offices and a graphic in most of the templates and I'm assuming along with all the autotext, the files on the server are taking up a LOT of space.

    Any suggestions would be appreciated.

    Thanks

  6. #6
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find and replace with multiple files (office 2000)

    Hi Leanne:
    Sorry for the delay in the response. I see that Gary has given you a macro. The INCLUDETEXT, or it's equivalent for a graphic, INCLUDEPICTURE, will work to insert a graphic. As Gary has pointed out, you can keep the graphic in a source document & just use a link (such as Includetext & Includepicture fields) in the templates.
    Cheers,

  7. #7
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Find and replace with multiple files (office 2000)

    Leanne,

    Rather than embed the logo into each template, you can store the logo as a separate file. If you place a bookmark in the template where the logo is supposed to go, you can use code like the following to insert the logo (as part of the routine that runs when a new document is created):

    <pre>If ActiveDocument.Bookmarks.Exists("bmkLogo") Then
    ActiveDocument.Bookmarks("bmkLogo").Range.Select
    Selection.Range.InlineShapes.AddPicture FileName:=sWorkGroupPath & "/RelevantSubfolder+FileName", _
    LinkToFile:=False, SaveWithDocument:=True
    ' Scale the logo
    ActiveDocument.Bookmarks("bmkLogo").Range.Select
    Selection.InlineShapes(1).Height = MillimetersToPoints(SingleValue)
    Selection.InlineShapes(1).Width = MillimetersToPoints(SingleValue)
    </pre>

    - the above is extracted from some more complicated code that pulls values from a DB, so it may not run as is, but should give an idea of how it can be done...

    Gary

  8. #8
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Find and replace with multiple files (office 2000)

    Leanne

    I don't recommend the include methods of bringing this data in unless the files ALWAYS reside on your network and the location of the data to include is accessible by all staff who might use the file.

    If you send the files to people without the network privileges to see the referred files then they may update the fields and not get the data you thought was in the file.

    The autotext won't be taking up file space in the created files, just in the template so I don't think that is a big issue.

    The biggest filesize space saver is to get the graphic right. I regularly see logos in documents that are way to big memory-wise for the task. Is it in bitmap or vector format? Can it be a vector format? If its a bitmap, does it need to be full colour or could it be saved as 1bit or 8bit colour depth?
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  9. #9
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Find and replace with multiple files (office 2000)

    Andrew:

    The graphic is saved as a jpg. I'm not sure what a vector is.

    If I delete the graphic from the template and save it, the file size goes from 1185 kb to 546 kb. The size of the graphic has to be H=0.5 and W=1.95 to match the logos on company printed stationary.

    Most of the offices are on a network (not directly hooked to mine though) so I'm assuming I could include an extra file with the logo to be brought in but then there are those that aren't on the network and those that also have the templates on their laptops.

    Any help would be much appreciated.

    Thanks

  10. #10
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Find and replace with multiple files (office 2000)

    Leanne

    If you can post the logo in question (the actual JPEG if you can), we may be able to downsize it so that it prints the same but doesn't take up so much file size.

    This might be via resampling (reducing the pixel count), recolouring (reducing the possible number of colours per pixel) or translating into a vector format (allows the graphic to be reproduced at any size in good resolution). We do need to see the logo to work out what is the best method of optimising it for this use.

    If the logo is a full colour bitmap (eg a jpg) and is only being used at sizes less than 2 inches wide then it doesn't need to be any more than about 300 pixels wide. Any more than this is just making for big files with no appreciable increase in viewing/printing quality.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  11. #11
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Find and replace with multiple files (office 2000)

    Leanne

    That logo is very simple and way oversized for your purposes. The problem with the JPG format is that Word is storing it in the full expanded file size and not in the compressed JPG format that was inserted.

    I have attached a Word doc containing the redone logo in two possible formats. With both versions included in the Word file, the file size is only 23Kb and an empty Word file is normally 15Kb by itself.

    I traced the logo and saved it as an EMF (2Kb) and also converted the JPG into a 3 colour GIF (3Kb). Both of these are a much better proposition than the JPG you were using. You will notice some artifacts in the GIF as the 3 colour limit doesn't give you any anti-aliasing to smooth the edges. If you wanted to use the GIF format then you would need to retouch the dud pixels to fix it up.
    Attached Files Attached Files
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  12. #12
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Find and replace with multiple files (office 2000)

    Hi Leanne,

    Another thing to bear in mind if you decide to use the INCLUDE approach is that it will change what's in any 'archived' documents next time you open them, which could be misleading.

    Likwise with the search/replace approach you're working on now - you may need to quarantine some files so that they don't get updated if they should remain static.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  13. #13
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Find and replace with multiple files (office 2000)

    Andrew:

    I didn't realize my logo came out at the bottom of text - way too large. Thanks for the rework and I'll put it in some templates and recheck the file size. The bad thing is I believe in a few months the logo will be changing so I may have to check back with you then again.

    Thanks for the help - much appreciated.

  14. #14
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Find and replace with multiple files (office 2000)

    Leanne

    I am used to logo's/branding changing so I know how you feel.

    I must say I am not surprised because when I saw the logo I thought you worked for SETI - the Search for Extra Terrestrial Intelligence. <img src=/S/alien.gif border=0 alt=alien width=14 height=15>
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  15. #15
    2 Star Lounger
    Join Date
    Jul 2001
    Location
    Wisconsin, USA
    Posts
    193
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Find and replace with multiple files (office 2000)

    Andrew - and some days I feel I work with a bunch of aliens!

    Again, thanks for your help. BTW - is there a way you can edit the post where the large graphic is under my message?

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •