Forum Discussion
ksmith
May 28, 2021Brass Contributor
Change workbook name in multiple macros
when I create a new workbook from an existing, in which there are multiple macros that refer to the original workbook, Can a macro be written that will change the workbook name in all of the macros s...
- May 28, 20211. You should look into how to share code as an add-in. That way, there's no proliferation of your code. If you want to fix a bug or enhance a code, you only have to worry about the code in the add-in. If, on the other hand, you are sharing code in a XLSM, there's no way you can find all the workbooks that contain your code, let alone fix all of them.
2. If you must stay with the current architecture, look at VBA objects ThisWorkbook and ActiveWorkbook. When you use those constructs your code will be independent of the name of the workbook containing it as well as independent of the workbook the user is currently working with.
tusharm10
May 28, 2021Brass Contributor
1. You should look into how to share code as an add-in. That way, there's no proliferation of your code. If you want to fix a bug or enhance a code, you only have to worry about the code in the add-in. If, on the other hand, you are sharing code in a XLSM, there's no way you can find all the workbooks that contain your code, let alone fix all of them.
2. If you must stay with the current architecture, look at VBA objects ThisWorkbook and ActiveWorkbook. When you use those constructs your code will be independent of the name of the workbook containing it as well as independent of the workbook the user is currently working with.
2. If you must stay with the current architecture, look at VBA objects ThisWorkbook and ActiveWorkbook. When you use those constructs your code will be independent of the name of the workbook containing it as well as independent of the workbook the user is currently working with.
ksmith
May 29, 2021Brass Contributor
thanks for the quick answer for above question.
this may be over my head as I am not to great with VBA but s-l-o-w-l-y learning the basics. Is there a tutorial that you could recommend for VBA?
this may be over my head as I am not to great with VBA but s-l-o-w-l-y learning the basics. Is there a tutorial that you could recommend for VBA?