Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-10-2015, 11:14 AM
jc491's Avatar
jc491 jc491 is offline How To Apply A VBA Macro to All Subfolders in a Directory of a docx. Extension Windows 7 64bit How To Apply A VBA Macro to All Subfolders in a Directory of a docx. Extension Office 2013
VBA Novice
How To Apply A VBA Macro to All Subfolders in a Directory of a docx. Extension
 
Join Date: Sep 2015
Location: UK
Posts: 55
jc491 is on a distinguished road
Default How To Apply A VBA Macro to All Subfolders in a Directory of a docx. Extension

Hi,
I am a novice VBA user.
I have about 300 files I need to process. I would like to apply a macro to all the files.
When the Files are in a standard folder I can use the macro below. It works perfectly.

It finds the files of a .docx type and applies a macro to it.


I now need help with a macro that will go through all the subfolders in the directory and apply my macro.
I have tested many versions of loop through directory VBA codes and have had no luck in getting the codes to work.







Sub ApplyMacroToAllFiles()
Dim file
Dim path As String
path = "C:\Users\\Desktop \Folder\"
file = Dir(path & "*.docx")
Do While file <> ""
Documents.Open FileName:=path & file

Call RemoveallBoldWords
ActiveDocument.Save
ActiveDocument.Close
' Set file to next in Dir


file = Dir()
Loop
End Sub

I simply need to be able to process the documents in the sub folders.
If any one can help me I would be so grateful. I have spent 2 days testing different VBA directory loop codes from the internet with no success.
I get run time errors, no response from the macro. It's really frustrating.



Thank you in advance
J
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How To Apply A VBA Macro to All Subfolders in a Directory of a docx. Extension Run a macro on multiple docx. files Peter Carter Word VBA 27 12-15-2022 04:10 PM
Help - Need Macro to Apply Blur SSL PowerPoint 6 07-26-2015 08:59 AM
.wda file extension added after .pdf, .docx, .xls, etc. GaryofLG Outlook 1 06-07-2015 11:13 PM
How To Apply A VBA Macro to All Subfolders in a Directory of a docx. Extension Macro to apply style to selected tables ubns Word 1 08-02-2012 04:09 AM
How To Apply A VBA Macro to All Subfolders in a Directory of a docx. Extension Macro to loop in subfolders, change links, export xml data Catalin.B Excel Programming 2 09-08-2011 11:37 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:28 PM.


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