Mark — your site is great, thanks. I have Looping through all the files subfolders working perfectly as is. Then you will have a known number of items. Next, loop through through the array to the copy the files to the right locations. I am trying to use your code to apply a password to all files within a folder and its subfolders but struggling. I am using the macro below to apply a password to all files within a folder — not sure if this is the reason I am struggling! Hello awesome work.
I am a bit of a novice and need some help. On running my macro it asks for a unique number. Say I enter and hit enter. It then needs to find a word docx with this number in the file name. Can you help please? This variable should be declared before any Subs to ensure it is visible to all macros within the module.
Hi I want to check if the folder name entrred through inputbox is present in the parent folder ir not. If the folder structure you are working with results in a path greater than characters for your string variable VBA throws and error. Is there a method around this? After finding their folder structure was not critical and was the result of people dropping files and creating a structure haphazardly I restructured their folders and had no problem.
The question still stands, if I could not restructure the folders is there a work around? When I get a bit of time, I might look into it. I have the same issue.
It looks like that when going through folders, files name are not all retrieved as the number of characters for both folders and file names is too long. This appears to be a long-standing issue with Excel, there are quite a few forum questions on similar things. Which version of Excel are you using? I have created a macro which selects the each excel file placed in folder and run the code, copies the value and save. Hi Pavan — The macro is running in alphabetical order.
To get it to run in the order you want, you will need to change to H1 and H2 to H01 and H A full file path is just a text string. So you would need to split and manipulate the strings to work out where the number is, then execute it in number order.
This code is great and I am hoping to build on it to get what I need. I have been trying for some time to get a full list of content in a sub folder structure similar to what is achieved here but I also need to include: path to empty sub folders.
I assume that I need to tweak these two lines of code, but I am now at a bit of a loss. Are you able to help? Could you help, please. Print FSOFile. Instead of creating a txt box in each file, the script creates 5 boxes one per sample file in the blank presentation.
Any help would be hugely appreciated. Slides 1. Hi Mark, The post is the best out of all the other info I found on other sites. I need small help here along with looping through the files in folders. Is there a way to check the modified date of the files in the path and to the recent files I need to run the specific macro.? This was very helpful in getting going in the right direction. My goals to be able to save each file updated with the actions as a new one.
I tried this but no luck.. My end goal is to update some files that all have the exact same set up just different data values and be able for them to save in a new folder. Please let me know if you have any recommendations or leads on the next steps. I have a OneDrive excel sheet open on my local PC. I have a macro which creates an invoice in pdf format and saves it to a sub-directory on my OneDrive. All ok so far. Subsequently, I need to use another macro to email the pdf invoice.
I am using the same OneDrive url both to create the pdf and retrieve the pdf. Your code above helps with half of my problem. I needed to get the file names and extensions to be able to dynamically create hyperlinks for each unique part number record in teh form. Any help would be greatly appreciated.
This is absolutely a bundle of treasure like others said. Your instructions are very clear and simple. It helped me to solve the last part of a puzzle — writing a program to loop through a folder where ten subfolders hold many legal cases I need to read and count the pages for each file.
These work incredibly, thanks for these treasures as others have said. Are they faster or something? The Dir method seems to work fast enough in my opinion. Would be interested to know if anybody else has done one. Your email address will not be published. Automate Excel so that you can save time and stop doing the jobs a trained monkey could do. We'll respect your privacy and you can unsubscribe at any time.
Looping through all the files in a folder The example we are looking will print the file name to the immediate window. For example: 'Loop through each file with an extension of ".
The book contains: example codes to practice reading and writing macros that will embed the language into your thinking. An introduction to macros in Excel to ensure you can implement the VBA code in the book even if you have no prior knowledge. Consistent code layout between examples to enable you to understand the structure and easily customize the code to meet your needs. Downloadable workbook containing all the source code , so the examples can be added to your project to give you the benefit of VBA straight away.
You will benefit much more by discovering your own solutions. Remember, the people on these forums are generally giving their time for free. Use Excel Rescue , who are my consultancy partner. Option Explicit If WScript. Hi John, Thank you for this. As far as I understand this will allow me to send variables to VBS file saved on the drive, correct? What if I wanted to integrate the VBS code inside excel - i.
Is that possible? Rgds, Greg. Yes, my code shows how to send variables arguments to the VBScript file. For example, you don't need WShell and therefore "WShell. The code can then be run in Excel in a VBA module.
However, the VBA versions of AppActivate and SendKeys are unreliable - they might work or they might not or you might get varying results. Thank you John. I have had no time to test it yet, but will let you know as soon as I do it. You must log in or register to reply here. Similar threads. Replies 0 Views 2K. Nov 11, davewatson CyberCorenez Oct 1, Excel Questions. Replies 2 Views Oct 1, Fluff. Question Applications blocks Subroutine from continuing.
Asked 9 years, 2 months ago. Active 6 months ago. Viewed 48k times. Amal G Jose 2, 1 1 gold badge 17 17 silver badges 31 31 bronze badges. Arup Rakshit Arup Rakshit k 27 27 gold badges silver badges bronze badges. As it is a duplicate, I voted to close it as a duplicate. Add a comment. Active Oldest Votes. Run "T". Alex K. Hi Alex, i want to call a. Can you clarify your suggestion please?
The shell line runs a vbs Alex, would you mind adding one more detail to your answer? ScriptControl" , which is the only option in some environments. Show 1 more comment.
0コメント