Dynamically Create Buttons

10sGerar

New Member
Joined
Apr 7, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello,
Brand new to the forum and brand new to VBA. I have a case where I need to list all the files in a folder and create a hyperlink to them and dynamically, create and "Edit" button next to each file name. I managed to list the files with hyperlinks (thank you google). The second part of my task has proven to be more difficult. In my job, I need to edit file names. For example, the file "File_001" I have to rename it "04.06_File_001". So, to avoid navigating the folders I figured that it would be a good idea to list all the files and then add a button next to them that says "Edit". When I click the button, a pop up window comes up with the name of the file. I can rename the file and save it and it will update the file name in the folder. I'm pretty sure I can figure out how to do the renaming and saving but, for the life of me, I can't figure out how to dynamically create a button next to each name on the list. Any ideas. Thank you
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
It seems you found out how to loop through the folder(s) and get the paths. Why not just loop through and rename? There are code examples everywhere about how to do this, some of which are on this site. I would back up the folder before running any code for the at least first time though.
 
Upvote 0
It seems you found out how to loop through the folder(s) and get the paths. Why not just loop through and rename? There are code examples everywhere about how to do this, some of which are on this site. I would back up the folder before running any code for the at least first time though.
The problem is that I don't need to change ALL the names with the same date nor I can't do it all at once. Let me give you some more information so you can understand better. What I have in those folders are statements for payments we will receive in the near future. We receive the statement and we save them with the name of the company and the amount in the name. Once the payment hits our bank account we add the date we received the payment at the beginning of the name. So the problem is that each file has a different date. Also, when we receive the statement and I'm saving the file in the folder, I never know how long will it take for the payment to come through. Also, I'm not in a position to change these rules since it's a whole team that works around this system. So my idea was to have a button next to each name and once the payment comes through I hit the "Edit" button next to the statement name and I edit and save the new name like that.
 
Upvote 0
Sample data that shows inputs and desired results would probably help others to help you. All that explanation doesn't help to focus on a solution (at least not for me). If all you want to know is how to dynamically add buttons in particular locations I can't help with that. However, there's likely a simpler solution, such as double clicking on the cell where you might want that button to be, then knowing the address of that cell, get the adjacent information (e.g. file name and/or date or whatever). Or maybe select cell(s) containing the info and use only one button that refers to the active cell and/or adjacent cells. I just don't see having a button for every file or operation, especially if you have to customize the code for each one of them in order to get at the info you need.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,843
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top