Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 04-10-2013, 06:43 AM
Peter Carter's Avatar
Peter Carter Peter Carter is offline Run a macro on multiple docx. files Windows 8 Run a macro on multiple docx. files Office 2013
Novice
Run a macro on multiple docx. files
 
Join Date: Mar 2013
Posts: 11
Peter Carter is on a distinguished road
Default Works

Paul thank you, I used your streamlined code with the addition of the line ". MatchWildcards = True" just before the end and it worked good. So the full code looked like this:

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 & "\*.docx", vbNormal)
While strFile <> ""
  Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  With wdDoc
    With .Range.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchCase = False
      .MatchWholeWord = False
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
      .Text = "["
      .Replacement.Text = " ~"
      .Execute Replace:=wdReplaceAll
      .Text = "]"
      .Replacement.Text = "~"
      .Execute Replace:=wdReplaceAll
      .MatchWildcards = True
      .Text = "~*~"
      .Replacement.Text = " "
      .Execute Replace:=wdReplaceAll
    End With
    .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
What would I need to add to get this code to create a new folder and save the new files in that folder?

Last edited by macropod; 04-10-2013 at 01:50 PM. Reason: Added code tags & formatting
Reply With Quote
 

Tags
multiple files



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to open Docx files? mond_bees Word 12 08-29-2012 03:32 AM
Run a macro on multiple docx. files convert multiple csv files to multiple excel files mit Excel 1 06-14-2011 10:15 AM
Run a macro on multiple docx. files looking for macro for multiple files bolk Word 3 05-03-2011 05:46 AM
Run a macro on multiple docx. files macro to pull data from multiple files psrs0810 Excel 2 10-25-2010 01:49 PM
Icon for docx files Jazz43 Word 2 10-20-2009 08:34 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft